Write a simple number guessing game Python program. In thiscode, generate two random integers between 1-10 (both included) andask the user to guess these numbers in five attempts. Printappropriate responses to the user such as “You won!” or “Youfailed”
Solution
import random
# generating a random number
number = random.randint(1, 10)
count = 0
while True:
# taking user input
n = int(input(“Guess: “))
count += 1
if n == number: # number matched
print(“You won!”)
break
if count == 5: # count is over
print(“You failed”)
break
# Hit the
OR
OR