Lists and Functions : Strings in Functions


I'm getting an error when trying to concatenante and create a "Helloworld" statement and instead being told I need to get "Waynesworld." When I reverse it, I get a likewise error in reverse, saying that I need to get the "Helloworld" output.

Is this a bug?

I've even simplified the code to the following, and it still happens

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

print string_function(n)


Well the error message is telling you that their built in check to see if you completed it right used the argument 'Waynes' but it returned Helloworld instead of their argument. The reason why this is happening, is simply because you are returning n + "world". n is already set equal to "Hello", so no matter what you put in as the argument, you will return Helloworld.
To fix this, take a look at your function. Your simplified code is closer to being correct. The only problem is

Instead, you want to look at what the argument is. It's s, and you want to concatenate the argument with world, so in very simple fashion, you just need to return s + 'world'.
I hope this helped!


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