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 Conditional Value

Arturo Barradas
PLUS
Arturo Barradas
Courses Plus Student 7,526 Points

What am I doing wrong?

Question one passed correctly but question two is not

conditions.py
admitted = None
age = 13
if age == 13:
    admitted = True
else:
    admitted = False

4 Answers

Hi there,

I think the problem is that you're assigning a value to the age variable - the first challenge question says that it's doing that in the background - you don't need it there. It's most likely failing because your code is writing over the value that is set behind the scenes that the challenge is using to test. If you remove the age=13 line, it should pass.

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

Hi there! The answer by Katie is partially correct. You are overwriting what the challenge is sending in. But above and beyond that, the condition is supposed to allow anyone in who is 13 or older. This means the condition should be if age >= 13:

Hope this helps! :sparkles:

Ooh, you're right, good catch - I had just done this one so I thought I didn't need to read the directions again. That'll teach me - thanks, Jennifer!

Arturo Barradas
PLUS
Arturo Barradas
Courses Plus Student 7,526 Points

Thank you very much for your answer, however I have removed the age = 13 sentence and the system is now responding Oops! It looks like Task 1 is no longer passing.

That's right, there was one more thing - Jennifer caught that one. The challenge asks for 13 or older, which means you also need to have >= instead of ==.

Arturo Barradas
PLUS
Arturo Barradas
Courses Plus Student 7,526 Points

Thanks you very much, from here now I'm going to pay more attention to the instructions.