[Tutor] Repeating an action
F.Lee
aristotle831 at gmail.com
Sat May 12 16:54:32 CEST 2007
On 5/12/07, Alan Gilfoy <agilfoy at frontiernet.net> wrote:
> How do you 'tell' Python to repeat a certain action X amount of times,
> and then stop.
>
> I could use a 'counter' (see below), but that seems kind of clunky.
>
>
>
> counter = 0
> example = True
> while example:
>
> print "Do something"
> counter += 1
>
> if counter == 100:
> example = False
>
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
Hi,
Have you considered a "for" loop? It's quite a bit less "clunky":
for i in range(100)
print "Do something"
HTH,
<Lee>
More information about the Tutor
mailing list