Strings in functions


Hey guys I am stuck on exercise 7 on function recap, any help will be really appreciated

This is the error,

File "python", line 2
SyntaxError: invalid syntax

I don't understand why the syntax is wrong

n = "Hello"
    return s + "world"

print string_function(n).


a function should start with a def keyword:

def example():
    return "i am a function"

your def keyword is missing

n = "Hello"

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

print n + string_function(n)

Got error " Oops, try again. string_function('Hello') returned 'world' instead of 'Helloworld'
What's wrong with my code?


you update s to "world" while you should join them (s + "world") together with a + and then return it


Of course sorry silly error, thanks anyways


Yes you assign s to 'world'.. but this is a stupid, buggy exersice! It told me to write 'Helloworld', first i printet 'helloworld', wrong, then 'Helloworld', then it said THAT was wrong, because i should write 'Waynesworld', because apparently s was assigned to be Wayne, so when i made the code
n = 'Hello'
def string_funtion(s):
return (s + 'world')
print string_function(n)
This does write 'Helloworld', even though it just said i returned Helloworld (which it asked me to do!) it even wrote string_function(Waynes)
Btw, returning n + s gives the correct 'Helloworld', but it still says error, i hate this site, so many ■■■■ bugs!


n = "Hello"

Your function here!

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


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



I have the same problem. This isn't the first time this has happened. I'm not sure what the incentive is to 'go pro' when you cant even finish one of their exercises...


@bentleys550 instead of def string_function(s) try def string_function(n) ....that should work.