Skip to content

Commit

Permalink
num guessser
Browse files Browse the repository at this point in the history
  • Loading branch information
Alter-Sitanshu committed May 9, 2024
1 parent a38d261 commit ac32d0c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions numberguesser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import random
from replit import clear



while(True):
number = random.randint(0,100)
level = input("Select a difficulty level (Easy/Hard) : ").lower()
if(level == "hard"):
lives = 5
else:
lives = 10
print(f"You have {lives} lives remaining.")
while(lives>0):
guess = int(input("Enter your guess : "))
if(guess > number):
print("Too High")
lives-=1
elif(guess < number):
print("Too Low")
lives-=1
else:
print("You Won. Correct Guess !")
break
print(f"You have {lives} lives remaining.")
loop = input("Do you want to play again ?(yes/no) : ").lower()
if(loop != "yes"):
break
else:
clear()

0 comments on commit ac32d0c

Please sign in to comment.