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 trialRakshith Nayak
1,893 PointsIt keeps saying store_open is not true.
Could someone please complete the code for me.
store_open = None
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
time = "9"
if time in store_hours:
print("True")
else:
print("False")
2 Answers
Jennifer Nordell
Treehouse TeacherAlexander Davison is correct in that you need to remove the time = "9"
. First and foremost, this is overwriting what Treehouse is sending in. Treehouse is going to send in a store time (possibly multiple) and check if your code passes for what they send in. Secondly, your code would compare the string 9 to an array full of integer values.
Also, the challenge explicitly states that True and False should be assigned to store_open
and not printed. So in addition to what was written above, the bottom should be:
if time in store_hours:
store_open = True
else:
store_open = False
Hope this helps!
Alexander Davison
65,469 PointsGreat attempt! However, numbers and booleans (true and false) are special. If you put double/single quotes around numbers/booleans then Python would think that it's just a plain old string. But if you get rid of the double/single quotes, Python would regonize the number/boolean then instead of treating the data as a string, it would treat it as a number or a boolean! Also, the challenge said that it already created the time variable (when it said "I'm going to create a variable named time" that meant it already created the variable). Try getting rid of the
time = "9"
line of code and removing the double quotes around the "True" and "False" data.
store_open = None
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
if time in store_hours:
print(True)
else:
print(False)
Lastly, like what Jennifer Nordell said, you weren't supposed to print the boolean out, you were supposed to assign the boolean to the store_open variable. Try doing that and you should be good to go :)
(This should pass the challenge )
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
Good luck and I hope this helps you! ~Alex
:)
Rakshith Nayak
1,893 Pointshey, thanks for your input. Much appreciated
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsOops lol I forgot about that XD
Good catch! :) I'll give you an up-vote.
~Alex
Rakshith Nayak
1,893 PointsRakshith Nayak
1,893 Pointshey, thanks for your input. Much appreciated