Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

While with complex expression

import random

def random_loop():
    total = 0
    while (total < 10000000) and (total % 17 != 1) and (total ** 2 % 23 != 7):
        print(total)
        total += random.randrange(20)

        # do the real work here

    print("done")

if __name__ == '__main__':
    random_loop()
0
12
25
26
34
50
65
77
done