Python Forum

Full Version: SyntaxError: EOL while scanning string literal on with open() statement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi! I am getting this error message in Python 3.6.3, using Spyder 3.2 in Anaconda 5.0.1 on Windows 7.
^
SyntaxError: EOL while scanning string literal
The interpreter is pointing to the colon at the end of the first line...

with open ("hello.txt', 'w') as f:
    f.write('writing over hello world')
This docs page says in section 7.2 that is how it's supposed to be written in Python 3. Python 3 Documentation

What is wrong with the code here? Huh Thank you..
you open with " but never close it
with open ("hello.txt', 'w') as f:
should be:
with open ("hello.txt", 'w') as f:
Ah, thank you! Just needed to increase the font size in Spyder with Ctrl+.
No, you just needed to close the string you started. :P