Python breaks for a certain amount

Posted by Brian Cox on Stack Overflow See other posts from Stack Overflow or by Brian Cox
Published on 2014-08-19T10:06:30Z Indexed on 2014/08/19 10:20 UTC
Read the original article Hit count: 181

Filed under:

All, I am not very good at explaining so i will let my comments do it!

#this script is to calculate some of the times table up to 24X24 and also miss some out
#Range of numbers to be calculated
numbers=range(1,25)
for i in numbers:
    for w in numbers:
        print(str(i)+"X"+str(w)+"="+str(i*w))
        #here i want to break randomly (skip some out) e.g. i could be doing the 12X1,12X2 and then 12X5 i have no limit of skips.

Update

Sorry if this is not clear i want it to break from the inner loop for a random amount of times

© Stack Overflow or respective owner

Related posts about python