We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 96d9d0c commit 62f2a04Copy full SHA for 62f2a04
guess_number.py
@@ -0,0 +1,21 @@
1
+import random
2
+
3
+number = random.randint(1, 50) # computer picks a number
4
+chances = 5 # total chances for user
5
6
+print("🎮 Welcome to Guess the Number!")
7
+print("Guess the number from between 1 to 50.")
8
+print(f"You have {chances} chances to guess it.\n")
9
10
+for i in range(chances):
11
+ guess = int(input(f"Chance {i+1}: Enter your guess: "))
12
13
+ if guess == number:
14
+ print("🎉 Correct! You guessed it!")
15
+ break
16
+ elif guess < number:
17
+ print("Too low! Try again.")
18
+ else:
19
+ print("Too high! Try again.")
20
+else:
21
+ print(f"\n😢 Game Over! The number was {number}")
0 commit comments