-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
29 lines (27 loc) · 827 Bytes
/
main.py
File metadata and controls
29 lines (27 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from random import randint
randomNumber = randint(1,100)
count = 0
# print(randomNumber)
while True:
usrInput = input("Guess the number: ")
count += 1
if usrInput.isnumeric():
# code for game
if int(usrInput) == randomNumber:
print("You win!!")
print(f"You guessed in {count} times!!")
break
elif int(usrInput) != randomNumber:
# print("You guessed it wrong. Try again")
if int(usrInput) > randomNumber:
print("You guessed a larger number. Try again")
else:
print("You guessed a smaller number. Try again")
else:
print("....")
pass
elif usrInput == 'Q':
print("Quiting...")
exit()
else:
print("Invalid input! Try again...")