Skip to content

Commit 6d6de93

Browse files
Merge pull request steam-bell-92#1147 from yuvraj-k-singh/bug/flipping-toss
[Bug]: Loop resets to initial prompt on invalid flipping toss game prediction input
2 parents 3676a0f + fa7607f commit 6d6de93

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

games/Flipping-Toss/Flipping-Toss.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ def main():
1616

1717
if choice == "y":
1818
num = random.randint(1, 2)
19-
# User prediction
20-
prediction = input("Predict the result (H/T): ").lower().strip()
19+
20+
# Sub-loop for validating user prediction without resetting the game loop
21+
while True:
22+
prediction = input("Predict the result (H/T): ").lower().strip()
2123

22-
if prediction not in ["h", "t"]:
24+
if prediction in ["h", "t"]:
25+
break
2326
print("❌ Invalid prediction!! Please enter 'H' or 'T'.\n")
24-
continue
2527

2628
print("🪙 Flipping...")
2729
time.sleep(2)
@@ -67,4 +69,4 @@ def main():
6769

6870

6971
if __name__ == '__main__':
70-
main()
72+
main()

0 commit comments

Comments
 (0)