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

traolach trewhella
PLUS
traolach trewhella
Courses Plus Student 835 Points

can someone show me how this answer is done! been having trouble its just i know im messing up on line three

and how can i define my code better i.m doing something wrong. show me the lesson clear and how its done. be glad to give best answer(:

membership.py
store_open = None
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
if store_hours in store_open: = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
  print("come on in")
  else:
    print("sorry we're closed")

2 Answers

Hey Traolach,

It looks like you were on the right track but you may need to reread the instructions. Be careful with challenges as sometimes there are variables not shown in the code space. For example, the instructions say there has already been determined a variable named time and we are asked to make an if statement to see if time is in store_hours. Also, when using conditionals like if, they will end with a colon.

I have an example below that passes :)

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

Hope this helps!

Changed to answer.

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

The challenge says it will provide a variable time. The code needs to check to see if time is in the store_hours:

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

# Is 'time' in store hours?
if time in store_hours:
    # Yes! set store_open to True
    store_open = True
else: # <-- else indent must align with 'if'
    # No, set store_open to False
    store_open = False