+ 1

Why won't this work?

Hello, I am attempting to write my very first solo code after a few lessons on python. I am being taught in python 2, but writing in 3 so that may be the issue. However, I am having trouble figuring it out, whatever it is. The console states my error to be Invalid Syntax on line 6, So if anyone could answer what's wrong with my return value that would be very helpful. Thank you very much. This is the code: #This code will show why Brian smelt of elderberries! #P.S. Brian is a friend of mine and I plan to show him my first solo code. userinp = input() def brian_elderberries(userinp: return userinp + 1 print("Enter a number between 1 and 10") def test(userinp): if userinp =< 10 and userinp >= 1: print "Brian added 1 to your number, just like always" elif userinp > 9: print ("That number is too high! Please enter a number between 1 and 10") elif userinp < 1: print("That number is too small! Please enter a number between 1 and 10") else: print("That's not a number! You and Brian both smell of elderberries!")

19th Nov 2018, 12:49 AM
Garrett Fischer
Garrett Fischer - avatar
2 Respostas
+ 3
Your line is missing the close parentheses. Change it to this: def brian_elderberries(userinp):
19th Nov 2018, 2:13 AM
John Wells
John Wells - avatar
+ 4
Also one of your print statements is missing parentheses, the input needs to be an integer (input() always generates a string) and you need to call your test function. Here it is with those things fixed https://code.sololearn.com/c88soAqEfNdm/?ref=app hint for next time : write your code in the playground and post a link 😎 also, =< isn't a thing - use <=
19th Nov 2018, 2:22 AM
David Ashton
David Ashton - avatar