[Tutor] While loop counter
John Fouhy
john at fouhy.net
Tue Jul 8 00:40:19 CEST 2008
On 08/07/2008, David <david at abbottdavid.com> wrote:
> Hi, I am trying to get a while loop that will execute 5 time then stop.
Hi David,
The standard pattern is like this:
i = 0
while i < 5:
# the stuff you want to do goes here
i = i + 1
Note that if you know exactly how many times you will execute your
loop, you should use a for loop instead:
for i in range(5):
# the stuff you want to do goes here
HTH!
--
John.
More information about the Tutor
mailing list