vendredi 24 novembre 2017

Continuously generate random number in python but stop when it generates a certain number

I want to continuously generate a random number between 1 to 10 but stop if it generates the number 9 or 10.

I'm using this to get the random number

import random for x in range(1): random.randint(1,10)

However, I don't know how to continue from there besides

if range<9 :
    print("Again")
elif:
    for x in range(1):
        random.randint(1,10)
else:
    print("End")      

Please help




Aucun commentaire:

Enregistrer un commentaire