Python Python Basics (2015) Logic in Python Membership

Luuk de Reus
Luuk de Reus
1,936 Points

I don't understand the IF and ELSE code format

I tried but failed. I don't know what I did wrong!

Thanks in advance Treehousers!

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

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 56,953 Points

You are SO close! The else needs to be indented the same amount as the if

And the colon (:) goes at the end of the if statement.

The colon is used to signify a block of code follows this statement, the code block should be indent. The first line not indented as much as the code block marks the end of the code block.

In this case, the unindented else ends the code block from the if statement.

Post back if you need more help. Good luck!!!