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 trialConnor Unwin
11,100 PointsWhy doesn't this code work in the code challenge?
I can't understand why this code is not working. At first I thought it was a indentation error but I've tried everything that I can think of. The if statement works fine but when I go to submit (Task 2) the else statement I get an error. Can someone help me please.
admitted = None
age = 13
if age >= 13:
admitted = True
else:
admitted = False
1 Answer
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsIt's a little confusing, but they already defined the variable age, outside of view. They are probably testing your code against a number of cases where age is set to a bunch of different numbers, so because you're reassigning 'age' and hardcoding it to 13 it's not behaving how it expects.
This is what you need:
admitted = None
if age >= 13:
admitted = True
else:
admitted = False
Connor Unwin
11,100 PointsConnor Unwin
11,100 PointsThanks for the help