Python print mystery – How to print without a space
Question:
How to have the same functionality as below in Python 2.7. No future please.
print(item, end="")
Answers:
Would this work for you?
import sys
sys.stdout.write(item)
Before the wonderful end=
(and sep=
) appeared in Python 3, I used to build up lines within strings and the print out the string in one hit:
str = "Three integers:"
for iii in range (3):
str = "%s %d" % (str, iii)
print s
Needless to say, I don’t code in Python 2 any more 🙂
How to have the same functionality as below in Python 2.7. No future please.
print(item, end="")
Would this work for you?
import sys
sys.stdout.write(item)
Before the wonderful end=
(and sep=
) appeared in Python 3, I used to build up lines within strings and the print out the string in one hit:
str = "Three integers:"
for iii in range (3):
str = "%s %d" % (str, iii)
print s
Needless to say, I don’t code in Python 2 any more 🙂