- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumber_guessing_game.py
More file actions
Latest commit
35 lines (30 loc) · 1.04 KB
/
Copy pathnumber_guessing_game.py
File metadata and controls
35 lines (30 loc) · 1.04 KB
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
30
31
32
33
34
35
importrandom
importcolorama
fromcoloramaimportFore
print(Fore.BLUE+'''
----------- NUMBER GUESSING GAME IN PYTHON ------------
''')
print(Fore.CYAN+"You have 5 chances to guess my number")
enter=input("Press enter to continue")
print()
chance=5
n=random.randrange(1, 50)
guess=int(input(Fore.RED+"Enter any number from 1 to 50: "))
whileguess!=n:
ifguess<n:
print (Fore.CYAN+"your guess is low think higher!")
chance-=1
print("you have",chance,"chance remaining")
ifchance==0:
print("play again")
chance=5
guess=int(input(Fore.RED+"\nEnter any number from 1 to 50: "))
else:
print (Fore.CYAN+"your guess is high think lower! ")
chance-=1
print("you have",chance , "chance remaining")
ifchance==0:
print("play again")
chance=5
guess=int(input(Fore.RED+"\nEnter any number from 1 to 50: "))
print(Fore.GREEN+"\nYour guess is correct YOU WIN")