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 trialBryan Diehl
1,937 PointsRoadblock 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
def age:
if age >= 13:
admitted = True
else:
admitted = False
Sean Hernandez
Courses Plus Student 9,350 PointsYes 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
231,248 PointsThere 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
22,687 PointsHi 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!!!
Sashi Shah
2,528 PointsSashi Shah
2,528 PointsHi 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.