I've been stuck at this problem for ages, and I just don't know what to do. I'm really new to python so I don't know much and I've just been stuck at this problem.
Every time I input my answer, it just endlessly repeats itself, even though it's the right answer, I looked for help with people who had similar problems but I just don't understand. Please help. Thanks.
Here's the Code:
print ("Hello World!")
# Name Input
name = input("What is your name sir? - ")
print ("Hello,",name)
# To see if they put the right Response
while True:
# The actual system to see if they got it right
try:
answer = int(input("Please say Y to play, or N to not play: "))
except ValueError:
print("Sorry please put either Y or N: ")
continue
else:
break
# if they did type the right answer, what will happen
if answer == "Y":
print ("Lets the game begin!")
elif answer == "N":
flag = False
# Beginning of game
import random
num = random.randint(1, 20)
flag = True
# the beginning of their guess
guess = 0
# Start of game
print ("Can you guess my number",name, "it's between 1-20", end = " ")
# The actual Guessing System
while flag == True:
guess = input()
if not guess.isdigit():
# if they don't put the number
print ("Sorry",name, "Please put numbers between 1-20 only. And remember, do Not put it in Word form")
break
# The system to see if they got the number
elif int(guess) < num:
print ("Sorry",name, "That's too low! Try again:", end = " ")
elif int(guess) > num:
print ("uhh",name, "That's too high, sorry", end = " ")
else:
print("That's Correct! My number is " +guess)
# End of Game
flag = False```