Limiting loop repetition in python -


i have program uses loop, thing though, how can make loop repeat given amount of times? code example below.

while true:     print "this should reprinted ten times" 

how can make code repeat ten, or given amount of times?

you can do:

for in range(10):     print "this should reprinted ten times" 

or

i=0 while < 10:     print "this should reprinted ten times"     i+=1 

or simply

print "this should reprinted ten times\n"*10 

for range , random number:

from random import randint num = randint(5,10) print "this should reprinted {} times\n".format(num)*num 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -