Skip to content

Commit 85b1a18

Browse files
feat: add number guesser
1 parent 9a5f5f4 commit 85b1a18

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import random
2+
3+
max_number = 100
4+
5+
print("\nWelcome to my game!\n"
6+
"Now I will generate a random number from 0 to 100 and you have to guess it."
7+
"\nLet's start...\n")
8+
9+
while True:
10+
number_to_guess = random.randint(0, max_number)
11+
12+
player_guess = int(input("Try to guess!\n "))
13+
14+
if number_to_guess != player_guess:
15+
print(f"You lost! The right number was {number_to_guess}")
16+
else:
17+
print("Well done! You won!")
18+
19+
choice = input("Do you want to continue? (y/N) ").capitalize()
20+
21+
if choice in ["Y", "Yes"]:
22+
continue
23+
else:
24+
break

0 commit comments

Comments
 (0)