We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9a5f5f4 commit 85b1a18Copy full SHA for 85b1a18
1 file changed
basics/03_control_flow/E1_number_guesser.py
@@ -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
24
+ break
0 commit comments