From 94855e63e14ada83813da0ea55bae211e41d4fba Mon Sep 17 00:00:00 2001 From: nadirhsan <168213279+nadirhsan@users.noreply.github.com> Date: Sat, 4 May 2024 17:44:16 +0530 Subject: [PATCH] Update main.py changed the y or n input to a loop to make sure program works even with wrong input --- Snake_water_gun/main.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Snake_water_gun/main.py b/Snake_water_gun/main.py index 5a8b1332894..23d8b51f5c3 100644 --- a/Snake_water_gun/main.py +++ b/Snake_water_gun/main.py @@ -22,21 +22,26 @@ class bcolors: run = True li = ["s", "w", "g"] -system("clear") -b = input( - bcolors.OKBLUE - + bcolors.BOLD - + "Welcome to the game 'Snake-Water-Gun'.\nWanna play? Type Y or N: " - + bcolors.ENDC -).capitalize() - -if b == "N": - run = False - print("Ok bubyeee! See you later") -elif b == "Y" or b == "y": - print( - "There will be 10 matches, and the one who wins more matches will win. Let's start." - ) +while True: + system("clear") + b = input( + bcolors.OKBLUE + + bcolors.BOLD + + "Welcome to the game 'Snake-Water-Gun'.\nWanna play? Type Y or N: " + + bcolors.ENDC + ).capitalize() + + if b == "N": + run = False + print("Ok bubyeee! See you later") + break + elif b == "Y" or b == "y": + print( + "There will be 10 matches, and the one who wins more matches will win. Let's start." + ) + break + else: + continue i = 0 score = 0