(Lists and functions) 7. Strings and functions


#1

I am currently stuck on this question, but I do not understand why. When I submit the code it says:

Oops, try again. string_function('Waynes') returned 'Helloworld' instead of 'Waynesworld'

What exactly does this mean, because the exercise does not mention anything about 'Waynesworld' or string_function('Waynes'). It only says:

Write a function called string_function that takes in a string argument (s) and then returns that argument concatenated with the word 'world'. Don't add a space before world!

I would be grateful to receive an explanation on this, thank you.

Also this is what my code looks like:

n = "Hello"
# Your function here!
def string_function(s):
    return "Hello" + "world"


print string_function(n)

#2

the great thing about functions is that we can use it to repeat the same task:

n = "Hello"
# Your function here!
def string_function(s):
    return "Hello" + "world"

# function calls
print string_function(n)
print string_function("Waynes")

the arguments get copied into the function parameter (s), so you can concate s and "world"


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.