Creating Guessing Game using Python3

What is a Guessing Game?

In a number guessing game, you have to guess a randomly chosen number by a computer. It must be felt simple on listening but it is as hard as other games played, when the range of number increases and the number of chances decrease.

"""In this code, we will be taking 100 chances for the player."""

import random
chance = 100
r = random.randint(1,100)
while chance > 0:
			n = int(input("Enter your guess"))
			if n > r:
				print("Guess is high")
				chance -= 1
			elif n < r:
				print("Guess is low")
				chance -= 1
			else:
				 print ("You guessed it right")
				 break

0 Comments