-2

i am creating a txt file in juypternotebook

%%writefile test.txt
hello this is my first line
hello this is my second line 

after that when i am appending some lines in that txt file by writing the code

with open ('test.txt' ,mode = 'r') as f:

then this error appears

File "<ipython-input-9-e008d94f1356>", line 1
    with open ('test.txt' ,mode = 'r') as f:
                                            ^
SyntaxError: unexpected EOF while parsing

please tell me why

Jim Lewis
  • 43,505
  • 7
  • 82
  • 96
vikash
  • 27
  • 5

1 Answers1

2

You can't start a with statement (or any block) and just end the script there, the block needs at least one command in it.

If you don't want to add the commands yet, use pass as a placeholder.

with open ('test.txt' ,mode = 'r') as f:
    pass
Barmar
  • 741,623
  • 53
  • 500
  • 612