import random
chance = 0
random_integer = random.randint(0, 10)
while chance <= 2:
n = int(input(“Guess the number between 1 to 10:”))
if (n < 0 or n > 10):
print("number out of range")
chance+=1
else:
# Generate a random integer between 0 and 10 (inclusive)
if (n == random_integer):
print("You Win")
break
elif (n > random_integer):
print("number guessed is greater than the lucky number")
chance +=1
elif (n < random_integer):
print("number guessed is less than the lucky number")
chance+=1
print(“Lucky number was:”,random_integer)
I tried installing lates python version and changing the python interpreter path to new one but still its not working.
New contributor
Omkar Lingvat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.