6.NumberMatchingGame.py
n1 = 21
max_chances = 9
for i in range(1, max_chances+1):
n2 = int(input("Enter your number:"))
chances_left = max_chances - i
if n2 == n1:
print("Congratulations! You found it")
print("No.of chance taken:",max_chances-chances_left)
break
else:
if chances_left == 0:
print("Game Over!")
else:
print("No. of Chances left:", chances_left)
# Add additional logic here if you want to do something after the loop
Comments
Post a Comment