While loop - print several times but on 1 line.
Sion Arrowsmith
siona at chiark.greenend.org.uk
Thu Jan 26 06:22:08 EST 2006
Danny <dannybuck1 at gmail.com> wrote:
>The programs output will be:
>text
>text
>(etc)
>
>How could I make this print: texttexttexttexttext?
>Ive researched and looked through google and so far I can't find
>anything that will help (or revelent for that matter).
I'm kind of surprised this isn't a FAQ (if it's in the FAQs, I
can't find it).
http://docs.python.org/tut/node5.html#SECTION005200000000000000000
tells you how to use
print "text", # Note the comma. Oh, and the correct comment character.
to get
text text text text text
http://docs.python.org/tut/node9.html#SECTION009100000000000000000
hints that what you want may be
sys.stdout.write("text")
to get
texttexttexttexttext
Beware that in either case you'll need an additional print at the
end of the loop to get the final newline back.
--
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
More information about the Python-list
mailing list