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

What is wrong with my code? SOLVED

I have trouble with this challenge: https://teamtreehouse.com/library/python-basics/logic-in-python/conditional-value

I think I have the right solution but I can't pass. I'd be very happy if someone more experienced Python programmer would point out what I'm doing wrong. Here is my code for the challenge:

admitted = None

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

The error I get is: Oops! It looks like Task 1 is no longer passing.

Ok, I figured it out. It seems that Python is very strict about how it's written. This passed the code:

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

2 Answers

Steven Parker
Steven Parker
229,644 Points

As you discovered, indentation is critical to Python's concept of grouping. Your original placement of the else put it inside the if group, without its own If.

Congrats on solving your own issue. You get a :star: for that. :wink:

Thanks for the star Steven!