Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python SyntaxError when using end argument with print function

Tags:

python

I don't know why i get the error because i have done exactly as the book says

>>> os.getcwd()
'C:\\Users\\expoperialed\\Desktop\\Pyt…'
>>> data = open('sketch.txt')
>>> print(data.readline(),end="")
SyntaxError: invalid syntax
like image 940
Rtttttttttttt Tttttrt Avatar asked Dec 04 '22 09:12

Rtttttttttttt Tttttrt


1 Answers

Or, to use the print function like you want in Python 2:

>>> from __future__ import print_function

That will need to be at the top of your Python program though because of the way the __future__ module works.

like image 188
DarkPrinceFrost Avatar answered Feb 09 '23 01:02

DarkPrinceFrost