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 trialDustin Vandehey
969 PointsConfused how to write the code for this...
I am not sure if the code is correct. I keep getting an error for this and am not sure if I have it written correctly. I think I have the write idea but am a bit stuck.
admitted = None
if admitted>13:
print("True")
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsYou're very close. The challenge want you to assign the value to admitted
after comparing the value of age
Is greater than or equal to 13:
admitted = None
if age >= 13:
admitted = True
Dustin Vandehey
969 PointsDustin Vandehey
969 PointsThanks Chris,
If I wanted to set admitted to false with an else, would you have to rewrite the if statement to say less than or equal to? I keep getting "It looks like task 1 is no longer passing." You know the videos make a lot of sense, and I seem to be able to type the code out fine in workspaces, but some of the challenges are a bit confusing or slightly different than the videos. Is it just a matter of lots of practice, or do you recommend a certain way of thinking about these questions? Thanks and really enjoying the coursework.
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsWhen the challenge says "Task one is no longer passing, it usually means there's a syntax error. Did you remember the colon at the end of the
else
. Also check you indentation.The
else
never has a conditional statement. The conditional for theelse
is the logical complement of theif
orelif
conditionals.The full solution should like similar to this
The language of the challenges is meant to use realistic terminology. Sometimes the descriptions aren't obvious but you learn as you go. It will become easier as you progress.
Always ask in the forum if you are stuck or unsure. That's what we're here!
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsFollow up. The challenge could have been written to accept these alternatives. But these both have more overhead.
Explicitly checking the else condition is slower. It also causes code reviewers more time to be sure the second condition is correct.
As two independent
if
statements, both have to evaluate regardless of theage
value