import random while True: a = random.randrange(20) print a if a == 10: break b = random.randrange(20) print b