- Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathq22.py
21 lines (15 loc) · 609 Bytes
/
q22.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Generate a random number between 1 and 9 (including 1 and 9).
# Ask the user to guess the number, then tell them whether they
# guessed too low, too high, or exactly right. (Hint: remember to
# use the user input lessons from the very first exercise)
importrandom
guess=random.randint(1, 20)
print("Enter a number between 1-20: ")
number=int(input())
whileguess!=number:
ifguess<number:
print("Your guess is too high, Try again!")
elifguess>number:
print("Your guess is too low, Try again!")
number=int(input("Enter a number again: "))
print("You got it!")