Why can't we indent 'break' as shown in the code?



Hi @textrockstar39356,

Your indentation places the break statement within the for loop, but not within the if block. Consequently, the break will execute during the first iteration of the loop, regardless of what items are in the cat list. Since 'star' is the third item, the loop does not have an opportunity to process it.

Indent the break statement to the same degree as the preceding print statement to place it within the if block, and see what happens. Then, change 'star' to something else, and observe a different result.

Most likely, you are using spaces, and not tabs, for indentation, but we cannot verify that merely by looking at the screen capture. If your are using spaces, continue to do so as you experiment with the code.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.