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

membership challenge

This is the task Task 1 : "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." I keep getting "'store_open' is not false" error Firstly I don't understand why it needs to be false time value could be with given range thus meaning it would be true. Am I assigning the false value to store_open correctly? Is there another way to do it? Reversing the logic using not gives the same result.

membership.py
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"

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You are sooooooooo close! :smiley: Your logic is spot on. However, you're not setting store_open to the boolean values True and False. You're setting them to the strings "True" and "False". Just remove those quote marks and you should be good to go! :sparkles:

edited for additional note

The reason you're getting the error that it should be false is because Treehouse is going to send in multiple times to your function to make sure that your code performs correctly no matter which time they send in. And when they sent in the first one, it should have returned the boolean value False. But what they got back was the string "False", which isn't the same thing.

Cheers.