-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
22 lines (17 loc) · 653 Bytes
/
app.py
File metadata and controls
22 lines (17 loc) · 653 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import random
def main():
secret_number = random.randint(1, 100) # Generate a random number between 1 and 100
guess = None
attempts = 0
print("Welcome to the Guessing Game! Guess a number between 1 and 100.")
while guess != secret_number:
guess = int(input("Enter your guess: "))
attempts += 1
if guess < secret_number:
print("Too low! Try again.")
elif guess > secret_number:
print("Too high! Try again.")
else:
print(f"Congratulations! You guessed the correct number ({secret_number}) in {attempts} attempts.")
if __name__ == "__main__":
main()