7/18: Strings In Functions. Help my understanding please


Hi everybody,
I have just completed this task yet am struggling to understand it nevertheless :confused:

n = "Hello"

#Your function here!

def string_function(s):
         return s + "world"

print string_function(n)

So my code worked fine, but I don't understand why it isn't :

  return n + "world"

as opposed to :

  return s + "world"

:checkered_flag: Thanks :checkered_flag:


Try this:
n = "Hello"

Your function here!

def string_function(s):
s = s + str("world")
return s

print string_function(n)


My code worked, it's just that I don't understand why its 's' as opposed to 'n'.


Never mind,
I understand now, I believe it's because the n is a global list as opposed to a local list (which in this case was s).


You got it! :grinning: