Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Error with finding value of variable

time = 15                                                                                       
store_hours = [1,2,3,4,5,10,11,12,13,14,15]                                                     
store_open = None                                                                               
 if time in store_hours:                                                                         
     store_open = True                                                                           
else:                                                                                           
    store_open = False                                                                          

bool(store_open)                                                                                
False                                                                                               
print(store_open)                                                                               
None                              

Why am i getting False & None when answer should be true since 15 is in store_hours?

[MOD: added ```python formatting -cf]

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,468 Points

After reformatting your question, the issue becomes clearer. There is an extra space in front of the if statement