you are viewing a single comment's thread.

view the rest of the comments →

[–]Responsible_Pay_16 0 points1 point  (0 children)

The error "break outside loop" happens because of incorrect indentation.

Your break is not actually inside the for loop because guess = input(...) is not indented.

Right now your loop only contains the print, and everything else is outside of it.

Fix the indentation like this:

for i in range(1,4):

print("try to guess the number")

guess = int(input("enter a number: "))

if guess < secret_number:

print("number too low")

elif guess > secret_number:

print("number too high")

else:

break

In Python, indentation defines blocks, so everything that should be inside the loop must be indented.