()
| 34 | |
| 35 | # Function to handle the toss |
| 36 | def toss(): |
| 37 | print("Toss time!") |
| 38 | user_choice = input("Choose heads (1) or tails (2): ") |
| 39 | toss_result = random.randint(1, 2) |
| 40 | if int(user_choice) == toss_result: |
| 41 | print("It's", "Heads!" if toss_result == 1 else "Tails!") |
| 42 | return 1 # Player 1 wins the toss |
| 43 | else: |
| 44 | print("It's", "Heads!" if toss_result == 1 else "Tails!") |
| 45 | return 2 # Player 2 wins the toss |
| 46 | |
| 47 | |
| 48 | # Function to handle the main gameplay for two players |