While loop - print several times but on 1 line.

Fredrik Lundh fredrik at pythonware.com
Thu Jan 26 06:10:39 EST 2006


Danny wrote:

> Great! It's been solved.
>
> The line, as Glaudio said has a "," at the end and that makes it go onto
> one line, thanks so much man!
>
> var = 0
> while <= 5:
>    print a[t[var]],
>    var = var +1
> prints perfectly, thanks so much guys.

if you wanted spaces between the items, why didn't you
say that ?

> How could I make this print: texttexttexttexttext?

>>> for i in range(5):
...     print "text"
...
text
text
text
text
text
>>> for i in range(5):
...     print "text",
...
text text text text text
>>> import sys
>>> for i in range(5):
...     sys.stdout.write("text")
...
texttexttexttexttext
>>>

oh well.

</F>






More information about the Python-list mailing list