EOF Error while Parsing

I am working on here.

Every time I try to get past:

with open('books.csv') as books_csv:

and when I run it I get the error:

File “script.py”, line 4

                                    ^

SyntaxError: unexpected EOF while parsing

It doesn’t let me get past the check point to move on.

1 Like

There must be more lines of code. Can post your complete script, please?

1 Like

There wasn’t more lines of code which is why it was odd that it said ‘line 4’.

Everything was written in line 3 and nothing more. While I wasn’t able to figure this out, when I went ahead and did the next project everything seemed to work fine.

1 Like

The instructions are very straight forward and simple to follow if you study the example in the lesson text. the line of code you have above is the second step.

1 Like

I am having the exact same problem in the exact same place. I even cut-and-paste the line of code from the solution (which was the same as my line) and it didn’t work.

Was this resolved?

Yes, it is only two lines of code. You have to get the green check on those two lines before you can proceed.

A code block must contain at least one statement following the block header. Therefore, if a block header is the final line that contains code in a program, the Python interpreter will raise a SyntaxError and issue a message that includes the following:

SyntaxError: unexpected EOF while parsing

Instruction 2 states:

2. Open up the file books.csv in the variable books_csv.

Since this requires the user to code a block header, a pass statement should be temporarily placed after that block header as a placeholder within the block by those who wish to click the Run button prior to completing the third instruction. The block header followed by the pass statement should appear as follows:

with open("books.csv") as books_csv:
  pass

After successfully submitting the code, users can remove the pass statement, then continue with the third instruction.

1 Like