0
I’m starting in python and I can’t figure out why the error below, could help me?
def SecretNumber():
GotIt = False
while GotIt == False:
One = int(input("Type a number between 1 and 10: "))
Two = int(input("Type another number between 1 and 10: "))
if (One >= 1) and (One <= 10):
if (Two >= 1) and (Two <= 10):
print('Your secret number is: ' + str(One * Two))
GotIt = True
continue
else:
print('Incorrect second value!')
else:
print("Incorrect first value!")
print("Try again!")
*****File "cell_name", line 14 Syntaxerror: 'continue' not properly in loop*****
Are you calling the
continue
out of a loop. The fact of its firstif
be recoilled less than thewhile
makes it not belong to the logical block of the loop repetition and thus in the line using thecontinue
, consequently, it will also be out of the loop - it is worth mentioning that in this way its loop of repetition is infinite becauseGotIt
never ceases to beFalse
.– Woss
That’s it Osvaldo, as Caio mentioned, the problem occurs because the continue works within a loop of repetition, is the python identifies the blocks of codes by identation, in your case your if stayed out of the block, while only 4 spaces in your complete if block and should work.
– Robson Silva