-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumberGuessing Game.py
More file actions
50 lines (39 loc) · 1.4 KB
/
NumberGuessing Game.py
File metadata and controls
50 lines (39 loc) · 1.4 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
print('''
___ _ _ ___ ___ ___ _____ _ _ ___ _ _ _ _ __ __ ___ ___ ___
/ __| | | | __/ __/ __| |_ _| || | __| | \| | | | | \/ | _ | __| _ \
| (_ | |_| | _|\__ \__ \ | | | __ | _| | .` | |_| | |\/| | _ | _|| /
\___|\___/|___|___|___/ |_| |_||_|___| |_|\_|\___/|_| |_|___|___|_|_\
''')
import random
print('Welcome to the number guessing game')
ch="y"
while ch=='y':
rang=int(input("The number to be guessed must be in between 0 and "))
num=random.randint(0,rang)
diff=input("Enter the difficulty level (Easy/Hard) :").lower()
if diff=="hard":
life=5
else:
life=10
print(f"Total number of lifes = {life}")
while life>0:
print(f"{life} life/lives remain")
guess=int(input("Enter your guess :"))
if guess==num:
print(f"Congrats you won with {life} life/lives remaining")
break
elif guess>num:
print("High,Guess lower")
life-=1
elif guess<num:
print("Low,Guess higher")
life-=1
else:
print("PROGRAMMER IS MAD ERRORORORORROORORROROO")
break
if life==0:
print(f"Sorry you lost the game.The number was {num}")
ch=input("Wanna play again?(y/n) :").lower()
elif guess==num:
ch=input("Wanna play again?(y/n) :").lower()
print("\n"*2,"THANKU")