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 Python Basics (2015) Logic in Python Membership

Micah Dunson
Micah Dunson
34,368 Points

Problem using 'in' function

The instructions are:

  1. Create a variable named "time" and store current hour
  2. Make an if condition that sets store_open to True if time is in store_hours. If time isn't in store_hours, set store_open to False. You'll probably have to use if, else, and in to solve this one

Code from challenge

store_open = None store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]

=================================================

// My Code Below for question

time = 12 if time in store_hours: store_open = True else: store_open = False

I keep getting this error: Bummer! store_open is not False. I don't see any error. Please help.

membership.py
store_open = None
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
time = 12
if time in store_hours:
    store_open = True
else:
    store_open = False

Hey Micah,

So your code is actually right! I think you just misread the challenge. In the first line they specify that they will make the variable. This is something you'll run into all the time here, Treehouse will feed your code some variable, string, tuple, list, ect.. And your code needs to do something to it. So all you need to do is delete like 3 ( time = 12 ) and this should pass!

1 Answer

Micah Dunson
Micah Dunson
34,368 Points

ughh... I hate when they do that and imply variables like that lol. It always throws me off. Thanks Ian!

Haha well get used to it! Kennith does it all the time. It looks like this isn't you aren't a stranger to treehouse. Happy coding!