print without intervening space

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Fri Aug 29 05:06:33 EDT 2003


Ernie wrote:
>>>>for x in range(10)

You forgot a ':' there...

> 
> ...   print x,
> ...
> 
> will output 
> 
> 0 1 2 3 4 5 6 7 8 9
> 
> 
> What if somebody wants instead
> 
> 0123456789

No problem:

 >>> import sys
 >>> for x in range(10):
...    sys.stdout.write(str(x))
...
0123456789>>>


--Irmen





More information about the Python-list mailing list