views:

105

answers:

2

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

A: 

Easy:

print x,

Note comma at the end.

Vladimir
This doesn't seem to do that
progo
x, leaves a space
san8055
Yeah, my fail :)
Vladimir
+5  A: 

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
progo
i want to print a variable not a string!
san8055
@san8055: I'm not following, I'll insert an example.
progo