0

I try to learn Python. The code can be written super easily but doesn't work. And when I write "break", it doesn't show up in the suggestions of PyCharm. I watch videos on Youtube and I did the same things that I watched. The same code works on the video, but in mine computer it doesn't work. What is the problem and how can I fix this?

s_Number=9
guess_count=0
guess_limit=3
while guess_count<guess_limit:
    number = input("Guess a number: ")
     guess_count+=1
  if number==s_Number:

      print("Well done!")
   break
E.Şevik
  • 11
  • 4

1 Answers1

0

SyntaxError: 'break' outside loop is caused due to your wrong indentation.

s_Number=9
guess_count=0
guess_limit=3
while guess_count<guess_limit:
     number = input("Guess a number: ")
     guess_count+=1
     if number==s_Number:
         print("Well done!")
     break

You can also place your break statement inside your if depending upon your intent.

mibrahimy
  • 722
  • 4
  • 18