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

J Aikman
PLUS
J Aikman
Courses Plus Student 427 Points

membership.py has bug

My code is below:

time = 15

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

What is the problem with this code?

Error message says syntax error on line 13 but there is no line 13? It would be useful if you posted the solutions. Obviously you have them ready as you have it programmed. This seems to be a glaring and easily fixed problem with Treehouse in general.

membership.py
time = 15

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

1 Answer

Thananjaya Chakravarthy
Thananjaya Chakravarthy
4,672 Points

You are close.. else statement cant have statement. Remove the statement and use just 'else'..