Skip to content

Commit 94855e6

Browse files
authoredMay 4, 2024
Update main.py
changed the y or n input to a loop to make sure program works even with wrong input
1 parent 902944d commit 94855e6

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed
 

‎Snake_water_gun/main.py

+20-15
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,26 @@ class bcolors:
2222
run = True
2323
li = ["s", "w", "g"]
2424

25-
system("clear")
26-
b = input(
27-
bcolors.OKBLUE
28-
+ bcolors.BOLD
29-
+ "Welcome to the game 'Snake-Water-Gun'.\nWanna play? Type Y or N: "
30-
+ bcolors.ENDC
31-
).capitalize()
32-
33-
if b == "N":
34-
run = False
35-
print("Ok bubyeee! See you later")
36-
elif b == "Y" or b == "y":
37-
print(
38-
"There will be 10 matches, and the one who wins more matches will win. Let's start."
39-
)
25+
while True:
26+
system("clear")
27+
b = input(
28+
bcolors.OKBLUE
29+
+ bcolors.BOLD
30+
+ "Welcome to the game 'Snake-Water-Gun'.\nWanna play? Type Y or N: "
31+
+ bcolors.ENDC
32+
).capitalize()
33+
34+
if b == "N":
35+
run = False
36+
print("Ok bubyeee! See you later")
37+
break
38+
elif b == "Y" or b == "y":
39+
print(
40+
"There will be 10 matches, and the one who wins more matches will win. Let's start."
41+
)
42+
break
43+
else:
44+
continue
4045

4146
i = 0
4247
score = 0

0 commit comments

Comments
 (0)
Please sign in to comment.