While you're here


#1



https://www.codecademy.com/courses/python-beginner-en-cxMGf/0/1?curriculum_id=4f89dab3d788890003000096#


File "python", line 9
break
^
IndentationError: expected an indented block


The "break" invocation is inside the loop I do not understand why I am getting an indentation error message.


<img src="//codecademy-discourse.s3.amazonaws.com/original/5X/8/c/8/6/8c868b01cdedeb9cbd32c2f805ca78274cbe7e1f.png" width="690" height="255">

count = 0

if count < 5:
    print "Hello, I am an if statement and count is", count
    while count < 5:
        print "Hello, I am a while and count is", count
    count += 1
    if count == 9:
    break


#2

The while loop should be outside the if condition.


#3

^ and you need to pay attention to your indentation. python relies on various indentation levels to read your code properly


#4

I ended up getting the code to work but I am still having some difficulty wrapping my head around indentation for conditionals, I figure the more I get through the loops set the more I'll understand thanks for the feedback.


#5

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