Advertisement
m1styyu

Untitled

Jul 7th, 2022
688
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2.  
  3. ticket_alphabet = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D']
  4.  
  5. def generate_ticket():
  6.     """Returns unique ticket"""
  7.     win_ticket = [random.choice(ticket_alphabet) for _ in range(4)]
  8.  
  9.     return win_ticket
  10.  
  11. win_ticket = generate_ticket()
  12. print(f"Билет {''.join(map(str, win_ticket))} является выигрышным")
  13.  
  14. def lottery_analyze(my_ticket):
  15.     attempts = 0
  16.     while generate_ticket() != my_ticket:
  17.         attempts += 1
  18.  
  19.     print(f"Потребовалось {attempts} попыток для получения выигрышной комбинации")
  20.  
  21. lottery_analyze(win_ticket)
Advertisement
RAW Paste Data Copied
Advertisement