Python Python Basics (2015) Logic in Python Membership

Christian Glaß
Christian Glaß
5,650 Points

Indentation Error - Python Error in line 15, but line 15 doesn't even exist...

As you can see in the headline, I get an error in line 15, but I didn't even write something in line 15. So I hope you can help me.

membership.py
time = 15

store_open = None
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]

if time in store_hours:
        store_open = True
    else:
        store_open = False  
Christian Glaß
Christian Glaß
5,650 Points

Sorry, I forgot the error-message. Here it is:

Bummer! Oh no! An error that I couldn't recover from. Here's what I know: IndentationError: unindent does not match any outer indentation level (<string>, line 15)

1 Answer

Andrey Misikhin
Andrey Misikhin
16,529 Points

Identation error on stroke with else, it is a part of "if", so identation not needed.

time = 15

store_open = None
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]

if time in store_hours:
    store_open = True
else:
    store_open = False 
Christian Glaß
Christian Glaß
5,650 Points

Thank you very much, didn't know that this could cause trouble.