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 trialAron Katz
700 PointsStill all messed up, no good here
I'm really tried of trying
admitted = None
age = 13
if admitted == 0:
print("great")
elif admitted == 13:
print("who cares")
1 Answer
Maurice Abney
Courses Plus Student 9,859 PointsPython is all about spacing. Your code seems like it should work, but elif's are companions of if's, not children of it. They must be on the same level.
This should work:
admitted = None
age = 13
if admitted == 0:
print("great")
elif admitted == 13: # notice I shifted the elif to be on the same level as the original if
print("who cares") # this needed to be shifted as well
Matthew Connolly
iOS Development Techdegree Student 11,595 PointsDon't get discourage Aron. Like Maurice said, it's all about the spacing in Python. Some languages use braces - Python uses spacing (and it NEEDS to be absolutely correct to run).
- Once you have the indenting correct, remove the
age = 13
variable on line 2. That is being provided, and you do not need to include. - Then, you can also change the
elif
to anelse
statement. Your only check will be in theif
clause (whether the age is above or equal to 13).
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsLet's keep the language appropriate.