List in function >> 7.strings in function


#1

help help help i am stuck what's wrong with m code .....
n = "Hello"

Your function here!

def string_function(s):
return n + 'world'
print string_function(n)


#2

hi @asad.itcgcs,

This is not your full code right? You did not type what n is before you defined the function. Also, try to follow the posting format, so that I can see your indentations (which is really important!). :frowning:

In any case, for this exercise, it is highly likely that your error is because you placed the print statement within the function itself. Check that your indentation is like this:

def string_function(s):
    return n + 'world'

print string_function(n)

so that you don't end up calling the function within the function itself (and after the return statement!)

Hope this helps :slight_smile:


#3

read the instructions carefully. "...takes in a string argument (s) and then returns that argument concatenated with the word 'world'."


#4

OH how embarrassing that slipped my mind :stuck_out_tongue:

of course @trevasco is right, I beg your pardon.


#7

thANK YOU MR.B HELPED ME A LOT :alien:


#8

It was MY pleasure :smirk::wink:


#9