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 trialNick Leeds
Courses Plus Student 316 PointsCan someone please help with this If statement from this exercise?
I'm going to create a variable named age. I need you to make an if condition that sets admitted to True if age is 13 or more
This is my code below (sorry if not formatted correctly) but why does it start with admitted = none?
admitted = None if age > 13: return admitted = True
admitted = None
if age > 13:
return admitted = True
3 Answers
Julian Gutierrez
19,201 PointsYou're close, there is no need to use return, simply set admitted to True.
admitted = None
if age >= 13:
admitted = True
Steven Parker
231,269 PointsStarting with admitted set to True
establishes a default value in case the condition does not change it.
But the instructions asked for a condition that "sets admitted to True if age is 13 or more", and the condition in the code above test for more than 13.
And you would only return from inside a function. Here you only need a simple assignment.
Nick Leeds
Courses Plus Student 316 PointsI am confused about the first line 'admitted = none' that is already in this exercise. Should this top line remain in this exercise before the If statement??
Nick Leeds
Courses Plus Student 316 PointsNick Leeds
Courses Plus Student 316 PointsSorry created a new post below but does the top line admitted = none remain as is provided in this exercise?