Having trouble with syntax


#1

Hey guys really new to coding and on my first program I’m stuck with this problem.

input ("\n\nPress the enter key to exit.")

File “”, line 0

^

SyntaxError: unexpected EOF while parsing
Familys-MacBook-Pro:desktop family$

This on a mac and everytime i try to hit enter to exit this keeps popping up. please help :{


#2

can you post your full code?


#3

Use python3 or use raw_input

You’re using python2’s input function. It doesn’t do what you think, don’t use it.

Additionally, it’s a bit strange for the program to keep running when it isn’t going to do anything more anyway!


#4

So i have downloaded and installed the latest version of python. re-wrote the basic code and I still get the same error


#5


#6

if you run python --version I doubt you’ll see 3.7


#7

I think what I would do is to create ~/bin or ~/.bin whichever you prefer - and add that directory at the start of $PATH so that it gets checked before everything else. Then you can put a symlink in there, you might want to add one for pip as well, both of them pointing into your python 3.7 installation

aliases might also do what you want, as an alternative. Or, you might already have it installed with an executable named python3 if it doesn’t bother you to type out the 3 as well


#8

Sorry :sweat_smile: I’m extremely new to coding and I’m having a hard time trying to figure out what your advising me to do. Can you dumb it down for me, I’m sorry :sweat:


#9

Difficult to suggest both what and how.

You have multiple python installations. That’s fine. But make sure to run the right one.


#10

@ionatan If I’m not mistaken, Isn’t the syntax based off py2 in Codecademys exercises?


#11

Not based off, it is python2

Which one is “right” depends on which one you picked when you wrote the code.

In python2, input doesn’t do what you think it does, what you meant was raw_input
raw_input was renamed to input in python3

So you needed to change one of them.


#12

Yeah, when i said based off py2, i meant they use python 2 not python 3.


#13

I think input is an acceptable property in py2 as well tho, but it’s just used in a different manner then raw_input. I may be wrong tho, it’s been awhile since I have used python.