Number Guessing Game

 #Number Guessing Game Objectives:


# Include an ASCII art logo.
# Allow the player to submit a guess for a number between 1 and 100.
# Check user's guess against actual answer. Print "Too high." or "Too low." depending on the user's answer.
# If they got the answer correct, show the actual answer to the player.
# Track the number of turns remaining.
# If they run out of turns, provide feedback to the player.
# Include two different difficulty levels (e.g., 10 guesses in easy mode, only 5 guesses in hard mode).
import random
def Number_Guessing_Game():
print("Welcome to the Guess the number Guessing Game")
print("I'm thinking of a number between 1 and 100.")

real=random.randint(1,100)
print(real)

choice=input("Choose a difficulty. Type 'easy' or 'hard': ").lower()


lives=0
if choice=='easy':
print("You have 10 attempts remaining to guess the number.")
lives=10
elif choice=='hard':
print("You have 5 attempts remaining to guess the number.")
lives=5
else:
print("enter valid input")


game_end=False
while(lives>0 and game_end==0):
guess=int(input("Make a guess : "))
if guess==real:
print("You Won")
game_end=1

if guess>real:
lives=lives-1
print("Too High")

if guess<real:
lives=lives-1
print("Too Low")


if lives==0:
print("The number I thought was "+str(real))



Number_Guessing_Game()

a=input("Do you want to play again ?(y/n)").lower()

while(a=='y'):
Number_Guessing_Game()
a=input("Do you want to play again ?(y/n)").lower()


Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings