Advertisement
furas

Python - three numbers match - (Stackoverflow)

Jan 21st, 2022 (edited)
615
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # https://stackoverflow.com/questions/70792478/how-can-i-get-my-program-to-display-match-when-three-numbers-are-the-sam
  2.  
  3. import random
  4.  
  5. # --- before loop ---
  6.  
  7. rolls = 50
  8. total_matches = 0   # PEP8: `lower_case_names` for variables
  9.  
  10. # --- loop ---
  11.  
  12. for i in range(rolls):
  13.     die1 = random.randint(1, 6)
  14.     die2 = random.randint(1, 6)
  15.     die3 = random.randint(1, 6)
  16.  
  17.     print(die1, "|", die2, "|", die3)
  18.  
  19.     if die1 == die2 == die3:
  20.         print("****MATCH*****")
  21.         total_matches += 1
  22.  
  23. # --- after loop ---
  24.  
  25. print()
  26. print("The total number of matches was:", total_matches)
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement