SyntaxError for lines of code which don't exist


#1

Hello! I am currently in the “Classes” section of the Python Learning Pathway and I have repeatedly gotten a SyntaxError for code which isn’t in my terminal.

SyntaxError: unexpected EOF while parsing

If I have one line of code, the error is on line 2. If I have 2 lines of code, the error is on line 3. I have submitted multiple bug reports and reached out to the help center but they told me they can’t do anything. I can’t move forward and I don’t want to skip something as important as classes.


#2

Hi @josephgibbons3799856,

Please post your code so we can examine it. Also supply a link to the exercise.

The error suggests that the end of your code occurred with something left incomplete. The problem may be that you did not close a string or a parenthesis. It could instead be that something else is missing. We’ll know more when we see your code.


#3

EOF means end of file, which, yes, in a sense, is after your last line


#4

Since this is an exercise on classes, and we have not yet seen the problematic code, a good guess would be that it contains a class definition header without any content following it, for example …

class Animal:

In that case, a pass statement would be a temporary cure here, until effective content is added …

class Animal:
  pass

#5

Thank you all for replying! The problem was, indeed, “pass”. I tend to take things literally and since the step only said to make the class and I assumed I would be filling it, I didn’t think to put pass. I got so frustrated I gave up for a few days. I now know that in the future I have to make sure to post my code, also. Thanks for taking the time to help!