0

Cane someone help me solve this and explain please, thank you.( i want store_open = None to change to True

time = 15 store_open = None store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18] if time == store_hours: print(store_open == True) else: print(store_open == False)

7th Apr 2017, 1:43 PM
Greg Bernabel
Greg Bernabel - avatar
4 Respuestas
+ 9
Oh yeah, right. Sorry, I'm not good at Python syntax. If you look at my codes, they're all in C++ ><
7th Apr 2017, 2:00 PM
Hatsy Rei
Hatsy Rei - avatar
+ 8
// You should be using assignment operator (=) instead of equality (==). time = 15 store_open = None store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18] if time == store_hours: store_open = True print(store_open) else: store_open = False print(store_open)
7th Apr 2017, 1:49 PM
Hatsy Rei
Hatsy Rei - avatar
+ 6
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 print(store_open) #For checking list use 'in' instead of '=='
7th Apr 2017, 2:19 PM
Mr.Robot
Mr.Robot - avatar
+ 1
thank you, it did work for me but with if time in store_hours: and everything else stayed the same.
7th Apr 2017, 1:57 PM
Greg Bernabel
Greg Bernabel - avatar