We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9b5732b commit fa7607fCopy full SHA for fa7607f
1 file changed
games/Flipping-Toss/Flipping-Toss.py
@@ -16,12 +16,14 @@ def main():
16
17
if choice == "y":
18
num = random.randint(1, 2)
19
- # User prediction
20
- prediction = input("Predict the result (H/T): ").lower().strip()
+
+ # Sub-loop for validating user prediction without resetting the game loop
21
+ while True:
22
+ prediction = input("Predict the result (H/T): ").lower().strip()
23
- if prediction not in ["h", "t"]:
24
+ if prediction in ["h", "t"]:
25
+ break
26
print("❌ Invalid prediction!! Please enter 'H' or 'T'.\n")
- continue
27
28
print("🪙 Flipping...")
29
time.sleep(2)
@@ -67,4 +69,4 @@ def main():
67
69
68
70
71
if __name__ == '__main__':
- main()
72
+ main()
0 commit comments