lundi 20 juillet 2020

How to limit the size of a list in Python while still making it change

I am currently setting up a lottery system for some friends and myself. At the moment I have the system set up fine however I want the system to stop adding numbers to the list and start checking the numbers against the predetermined ones I have set up. So far I have had no luck I am hoping someone could help. If needed I can copy and paste my code here for you to view. Thanks

import random
winning_numbers = [1,45,7,2,6]
user_numbers=[]
while user_numbers != winning_numbers:
  user_numbers = user_numbers[:1]
  user_numbers.append(random.randrange(1, 50))
  print(user_numbers)
else:
    print("Winner!")
    print(len(user_numbers))
if user_numbers > [5]:
    print("quit")
    exit()



Aucun commentaire:

Enregistrer un commentaire