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 trialsandhya sivasankaran
1,711 PointsIf else challenge
I was asked to set admitted to true if age >= 13 else false, i wrote the below code, what is wrong with it? its not passing for some reason
admitted = None if age >= 13: admitted = True else: admitted = False
admitted = None
if age >= 13:
admitted = True
else:
admitted = False
3 Answers
Antonio De Rose
20,885 Pointsadmitted = None #this is redundant, cause you can save it on the fly
if age >= 13:
admitted = True
else: #you have to have the else, aligned with the if, when it comes to indentation in python
admitted = False #this will also have to follow, accordingly.
Luis Miguel Hernandez
4,266 PointsRemember that the python code should always be indented, like this:
admitted = None #This line is not necesary
if age >= 13:
admitted = True
else:
admitted = False
sandhya sivasankaran
1,711 PointsYes it was the indentation. Thank you very much for helping.