Setting end variable on print

18 views
Skip to first unread message

saad khalid

unread,
Jan 3, 2017, 11:54:55 PM1/3/17
to sage-support
Hey everyone:

I would like to use the print function without it creating a new line. From what I remember, I could do print("whatever I want", end=""), and that should make it not create a new line. However, when I do this, I get an error saying

print("hi", end = "")
               
^
SyntaxError: invalid syntax


Justin C. Walker

unread,
Jan 4, 2017, 1:30:11 AM1/4/17
to sage-s...@googlegroups.com
I believe that the Python syntax is
print "hi",
(at least for Python 2; not sure about v. 3).

HTH

Justin

--
Justin C. Walker, Curmudgeon at Large
Director
Institute for the Enhancement of the Director's Income
-----------
If you don't know where you're going,
you might wind up someplace else.
- Yogi Berra
--

Nils Bruin

unread,
Jan 4, 2017, 3:53:49 AM1/4/17
to sage-support
That's python3. You can get that behaviour in python2 (and hence, presently, sage) by using

from __future__ import print_function
Reply all
Reply to author
Forward
0 new messages