4

How to have the same functionality as below in Python 2.7. No future please.

print(item, end="")
User
  • 483
  • 4
  • 19

2 Answers2

1

Would this work for you?

import sys
sys.stdout.write(item)
Iman K
  • 357
  • 1
  • 9
1

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 :-)

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953