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

Stumped on challenge task https://teamtreehouse.com/library/python-basics/logic-in-python/membership

Okay, so here's the body of the challenge task:

I'm going to create a variable named time. It'll be an integer for the current hour (well, what I want the current hour to be). I need you to 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.

Here's a screen shot of my code (included with the code provided in the question):

https://i.imgsafe.org/541d4dfdb3.png

I'm not sure where I'm going wrong with this one... thanks in advance for any help!

2 Answers

Couple things: Make sure to embed your code vs screenshot. And that your question is filed under specific challenge. Makes it easier to reference everything.

Below: No need to define time variable. Code challenge will do that. Remove time = 9, and code will work.

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

Awesome, thanks! I knew it was probably something incredibly simple that I just happened to miss.