Strings in functions


#1

n = “Hello”

Your function here!

def string_function(s):
return n + “world”

print string_function(n)

#whats wrong?
error:Oops, try again. string_function(‘Waynes’) returned ‘Helloworld’ instead of ‘Waynesworld’


#2

Hi try to change return n + "world" like that


return s + "world"


#3

Thank you, that worked for me! I don’t get it though, can you explain?


#4

Hi its work like that

First you declare a variable num and store " Hello" then you write a function with one argument which is s and the function return

return s + "World"

So when you call the function with n


string_function(n)

the n take the place of s inside the function and since we saved inside n Hello the call function print

#console 

Hello Word 

#5

Ohhh, I see. Thank you!


#6

thank you for the explanation. [this exercise seems simpler than it is]
(https://www.codecademy.com/courses/python-beginner-nzzVa/1/3?curriculum_id=4f89dab3d788890003000096)