forked from NitulKalita/Python-CLI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumber_guessing_game.py
More file actions
35 lines (30 loc) · 1.04 KB
/
number_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
import random
import colorama
from colorama import Fore
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: "))
while guess != n:
if guess < n:
print (Fore.CYAN+"your guess is low think higher!")
chance -= 1
print("you have",chance,"chance remaining")
if chance == 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")
if chance == 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")