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

Bryan Diehl
Bryan Diehl
1,937 Points

Roadblock when adding else condition

Cannot figure out why the else condition will not work. I double checked my indentation per the response by Alexey Kislitsin to Joe Thompson's question on Dec 30, 2016. I tried including "admitted = None" as well to no avail. What am I missing?

Thanks! Bryan

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

Hi Steven .. That is so weird. I did not have the admitted=None in my screen - I just copied and pasted what Bryan sent and it gave me the green signal. Now that I go there and see, there is an admitted =None, and you are correct, it didn't pass. That line should remain in Bryan's answer. I am going to delete my earlier comment.

Sean Hernandez
Sean Hernandez
Courses Plus Student 9,350 Points

Yes i agree you dont need to define age in your code python knows to create the variable age when running it through a if...else statement on its on so simpley

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

This should suffice for this challenge

2 Answers

Steven Parker
Steven Parker
231,248 Points

There seems to be two issues:

  • the original line supplied (that set admitted to None) should remain in the code
  • no function is being created here (the "def age:" line should be removed)
Thomas Fildes
Thomas Fildes
22,687 Points

Hi Bryan,

You don't need to create a function for this challenge. You just need to create an if/else conditional statement. Please see the below code I used to pass this challenge:

admitted = None

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

Hope this helps! Happy Coding!!!