[Tutor] printing without a new line
Don Arnold
darnold02 at sprynet.com
Sun Jun 13 13:38:30 EDT 2004
I'd suggest storing the individual convertxt() results in a list instead of
printing them as you go. Then, use the join() string method when you're done
to create a string from the list. Something like this:
>>> res = []
>>> for char in 'this is a test':
res.append(char.upper())
res.append(' ')
>>> print res
['T', ' ', 'H', ' ', 'I', ' ', 'S', ' ', ' ', ' ', 'I', ' ', 'S', ' ', ' ',
' ', 'A', ' ', ' ', ' ', 'T', ' ', 'E', ' ', 'S', ' ', 'T', ' ']
>>> print ''.join(res[:-1]) ##sliced to lose trailing space
T H I S I S A T E S T
>>>
HTH,
Don
-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On Behalf
Of Dragonfirebane at aol.com
Sent: Sunday, June 13, 2004 10:17 AM
To: tutor at python.org
Subject: Fwd: [Tutor] printing without a new line
I sent this out a couple of days ago; just wondering if anyone's working on
it.
Thanks.
"n thats the way the cookie crumbles"
America's Favorite Cookie
More information about the Tutor
mailing list