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

Aron Katz
Aron Katz
700 Points

Still all messed up, no good here

I'm really tried of trying

conditions.py
admitted = None
age = 13
if admitted == 0:
    print("great")
    elif admitted == 13:
        print("who cares")

Let's keep the language appropriate.

1 Answer

Maurice Abney
PLUS
Maurice Abney
Courses Plus Student 9,859 Points

Python 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
seal-mask
.a{fill-rule:evenodd;}techdegree
Matthew Connolly
iOS Development Techdegree Student 11,595 Points

Don'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).

  1. 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.
  2. Then, you can also change the elif to an else statement. Your only check will be in the if clause (whether the age is above or equal to 13).