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

Roland Vas
Roland Vas
1,967 Points

2nd Challenge Task if else Admitted question giving me trouble

This is my code, I believe it is correct, unless I'm not seeing something through correctly or I missed a rule on the if else conditions.

admitted = None

age = 14 if age >= 13: admitted = True else: admitted = False

The first part of the challenge i get a correct answer, on the 2nd part though I'm getting a Bummer! ' admitted' is not False message... if i change the age then the message is reffering to the first task not passing. Please help!

conditions.py
admitted = None

age = 14
if age >=13:
  admitted = True
else:
  admitted = False

3 Answers

The variable age is set by the challenge. Remove the line age = 14 else you'll overwrite the test setting it to less than 13. Hence, the expected result of False is never stored in admitted. The questions starts with I'm going to create a variable named age so you don't have to.

The code should look like:

admitted = None

if age >= 13:
  admitted = True
else:
  admitted = False

The challenge will run your code with age set to two values. If you change that value in the code, the test suite will assume, correctly, that your code isn't working as it expected.

I hope that makes sense.

Steve.

No problem! Glad you got it fixed. :-)

Cool

Challenge Task 1 of 2

I'm going to create a variable named age. I need you to make an if condition that sets admitted to True if age is 13 or more.

admitted = None

if age >= 13:

     admitted = True

Keep up the momentum!

Challenge Task 2 of 2

OK, one more. Add an else to your if. In the else, set admitted to False.

admitted = None

if age >= 13:

      admitted = True

else:

       admitted = False