MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / toss

Function toss

projects/HandCricket/main.py:36–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34
35# Function to handle the toss
36def 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

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected