Hello! I'm Parin, who started studying Python.
I opened it again to review the files I made last weekend Last weekend, when I did CMD-I, I could check it on the console without any problems
Suddenly, an InvalidSyntax error appears. Can I know the solution??
print('')
print ('separator option')
print('')
print('P', 'Y', 'T', 'H', 'O', 'N', sep='/')
print('010','7777','1234', sep='-')
print('python','google.com', sep=' @ ')
Error name:
line 20 print('P', 'Y', 'T', 'H', 'O', 'N', sep='/') ^ SyntaxError: invalid syntax
invalid
Isn't it the Python version? If you have both versions installed, please check the environment variable settings.
The Python 2.7 version does not support the sep keyword. If you write "from_future_ import print_function" on the first line, it will work.
#python 2.7.15
from __future__ import print_function
import sys
print(sys.version)
print('')
print ('separator option')
print('')
print('P', 'Y', 'T', 'H', 'O', 'N', sep='/')
print('010','7777','1234', sep='-')
print('python','google.com', sep=' @ ')
#python 3.7.1
import sys
print(sys.version)
print('')
print ('separator option')
print('')
print('P', 'Y', 'T', 'H', 'O', 'N', sep='/')
print('010','7777','1234', sep='-')
print('python','google.com', sep=' @ ')
Please check it out.
Thank you.
© 2024 OneMinuteCode. All rights reserved.