-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject_2.py
More file actions
22 lines (20 loc) · 746 Bytes
/
Project_2.py
File metadata and controls
22 lines (20 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import random
rand_number = random.randint(0,10)
#print(f"Random number = {rand_number}")
User_guess = None #This enables one to use User_guess variable even though it is yet to be defined
while User_guess != rand_number:
User_guess = int(input("Welcome, guess a number: ")) #It keeps asking user to guess while the condition is not Truthy!
if User_guess < rand_number:
print("You guess is too low")
elif User_guess > rand_number:
print("You guess is too high")
else:
print("You guessed right!")
Replay = input("Do you want to keep playing? ")
if Replay == "y":
rand_number = random.randint(0,10)
User_guess = None
elif Replay == "n":
print("Thanks for playing")
break
print(f"Actual number is {rand_number}")