The end keyword used with print statement is not working in my PYTHON UBUNTU(neither in sublime nor in pycharm ce nor in terminal. Not even by importing sys and time
I tried importing sys and time and using time.sleep(),sys.stdout.write(), sys.stdout.flush() too
This Is the Code
print("Hi",end=" ")
print("hello")
Error Message:
file "/home/ansh/Desktop/fun.py", line 3
print("Hello", end = " ")
^
SyntaxError: invalid syntax
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/home/ansh/Desktop/fun.py"]
[dir: /home/ansh/Desktop]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin: /bin:/usr/games:/usr/local/games:/snap/bin]
Looks like you're using Python 2.x instead of 3.x.
The same thing can be achieved in Python 2.x with this:
print "Hi",
print "hello"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.