Python Python Basics (2015) Logic in Python Membership

Maor Beeri
Maor Beeri
2,154 Points

can someone pls tell me why my code isn't wright?

thanks

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

2 Answers

Hoessein Abd
Hoessein Abd
Python Web Development Techdegree Student 13,018 Points

This works for me.

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
Maor Beeri
Maor Beeri
2,154 Points

thanks a lot! so the else statement must be aligned with the if statement?

Maor Beeri
Maor Beeri
2,154 Points

I tried to change the indentation, but it's still not working :(