Skip to content

Commit 7766484

Browse files
committed
Added missing file from last commit
1 parent 1adbbcb commit 7766484

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import random
2+
3+
def guess_the_number():
4+
number = random.randint(1, 100)
5+
attempts = 0
6+
while True:
7+
guess = int(input("Guess the number (between 1 and 100): "))
8+
attempts += 1
9+
if guess < number:
10+
print("Too low! Try again.")
11+
elif guess > number:
12+
print("Too high! Try again.")
13+
else:
14+
print(f"Congratulations! You guessed the number in {attempts} attempts.")
15+
break
16+
17+
guess_the_number()

0 commit comments

Comments
 (0)