Guess the hidden number | Game | Made with Python

 Guess the hidden number 


Hello everyone so here is my another code , It is a game in which a number is hidden a the user have to guess the number their are 10 chances to guess that number , after each guess it will tell the number you entered is bigger than hidden number or smaller. Enjoy the game. 

x=25
print("In this game you have to guess the number which is hidden,\nYou have 10 chances to guess the hidden number")
chances=1
while(True):
guess=int(input("Now enter your number\n"))

if guess==x:
print("Congrats you won by",chances,"guesses" )
opinion=input("To play again write yes and to exit write exit\n")
opinion.upper()
if opinion=='Yes':
continue
else:
print("Hope you enjoyed the game")
break
if guess>x :
print("Your number is bigger than hidden number\nTry again",chances,"chances used")


if guess<x:
print("Your number is smaller than hidden number\nTry again", chances, "chances used")

print(10-chances,"chances left")
chances = chances + 1
if chances==10:
print("Game over")
opinion = input("To play again write yes and to exit write exit\n")
opinion.upper()
if opinion == 'Yes':
continue
else:
print("Hope you enjoyed the game")
break

Comments

Popular posts from this blog

Single Inheritance, multiple inheritance and multilevel inheritance in python.

Git Commands.

Using class objects, Instance variables, and class variables, class methods and static method in python