Python Python Basics (2015) Logic in Python Membership

If and in statement

What did I do wrong in this work??

time = 15

store_open = [9] store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18] if time in store_hours: print("you are welcome to come in") else print("sorry, the store is closed")

membership.py
time = 15

store_open = [9]
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
if time in store_hours:
    print("you are welcome to come in")
    else print("sorry, the store is closed")

1 Answer

rshap
rshap
12,433 Points

Just indent the "else" line...

time = 15
store_open = [9]    # unused...
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]    # the same as: store_hours = range(9, 19)

if time in store_hours:
    print("you are welcome to come in")
else:
    print("sorry, the store is closed")