[Tutor] printing out a box of O's
Alan Gauld
alan.gauld at freenet.co.uk
Tue Mar 1 08:40:36 CET 2005
----- Original Message -----
From: "Kevin" <python.programming at gmail.com>
To: <tutor at python.org>
Sent: Tuesday, March 01, 2005 12:35 AM
Subject: [Tutor] printing out a box of O's
> there a better way to do
> this:
>
> j = 'O'
> for i in j*10:
> print i * 100
Its not bad, but the for loop could be 'simplified' to:
for i in range(10):
print j*100
its not any shorter and probably doesn't run much faster
but its a lot more readable because its the conventional
Python idiom for coding fixed length loops.
Alan G.
More information about the Tutor
mailing list