Print variable in python without space or newline

Question:

print a variable without newline or space
python3 does it by print (x,end=”)
how to do it in python 2.5

Asked By: san8055

||

Answers:

Easy:

print x,

Note comma at the end.

Answered By: Vladimir Mihailenco

sys.stdout.write writes (only) strings without newlines unless specified.

>>> x = 4
>>> print x
4
>>> import sys
>>> sys.stdout.write(str(x)) # you have to str() your variables
4>>> # <- no newline
Answered By: mike3996