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

Alistair Murphy
Alistair Murphy
743 Points

IF's, IN's and ELSE problem help.

error on non existent line 13 ?

membership.py
time = 15

store_open = None
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
if time in store_hours:
    print ('open')
else 
    print ('closed')

3 Answers

Maxime Duhamel
Maxime Duhamel
7,169 Points

Ok my bad,

I just had a look at the challenge you referenced.

The challenge is not about printing "open" or "close". They want you to change the value of store_open (which is none at the initialisation) to True if time is in store_hours and False if it isn't. You don't need to use the print function at all. I passed this challenge this way.

I hope it will work for you as well.

Alistair Murphy
Alistair Murphy
743 Points

Sorry little confused can you send the code you done so i can see what you mean. :s

Maxime Duhamel
Maxime Duhamel
7,169 Points
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 :
    store_open = False

Make sure you understand why as it is one of the core concept of many (if not all) programming language. No need to rush :)

Alistair Murphy
Alistair Murphy
743 Points

right yeah i thought i had to print so it did a thing, but just stating store_open = true, makes it thus. also one thing i noticed is CAPS for the beginning of True & False the fact it wasn't orange meant it wasn't a function. i should of noticed that. i'll make sure to excel at this in particular as i see so much use in it for my own projects to come. thank you very much max !!

Maxime Duhamel
Maxime Duhamel
7,169 Points

Always happy to help :) Yes booleans value in python start with caps. Syntax can be frustrating sometimes but it's worth it to overcome it. Keep learning and i wish you the best for your projects.

Maxime Duhamel
Maxime Duhamel
7,169 Points

Hi,

Not an expert in python but it might come from the absence of column after else. Try adding the column and see if it works.

Hope it helped

Max

Alistair Murphy
Alistair Murphy
743 Points

I don't think its that, gave it a go anyway, but seems to be something else that is the way to block it i believe. >.< thanks for trying !