+ 1
why doesn't this code work?
it says break is not part of the loop words = ["Python", "fun"] index = 0 words.insert(index, "is") if words == ["is","Python","fun"]: print('hi') elif words == ["is","is","Python","fun"]: break print(finished)
8 ответов
+ 1
break can only be used in a loop
finished should be in quotes
+ 1
Yup Yup
+ 1
the problem with the break is that it is used to get out of the loop (while,for). since if is not a loop python interpreter gets confused and asks you what do you want with your break there.
0
Im not sure about the break, but it looks like there arent any quotation marks around the word finished.
0
so break wouldn't be needed?
0
thanks
0
Try change the break command to pass and add quotationmarks to finished. Then it should work! :-)
0
break вне цикла. а где у тебя вообще цикл?