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 trialGurutej Battaram
2,224 PointsWhy won't the assignment in else block be done?
I have written a simple if-else condition for the challenge task, but it keeps returning the same error: "Bummer! 'admitted' is not False. I tried the exact same code in the console and it works fine. Please help me complete the challenge.
admitted = None
if age >= 13:
admitted = 'True'
else:
admitted = 'False'
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsFalse
and True
are key words in Python. They should not be quoted unless you wish to create strings. So when it says admitted is not False
it means it is not equal to the built in value. Remove the quotes.
Gurutej Battaram
2,224 PointsGurutej Battaram
2,224 PointsWow! Thank you Chris. Got it done!! One doubt though. I get that the challenge wouldn't complete because 'admitted' couldn't be assigned False because of the quotes. But how did it work for True? Because that was the first task of the challenge, to assign 'admitted' the value of True and it worked with the quotes.
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsThe grader runs your code with various values for
age
to test the branches in the code flow.When testing for
True
the grader may use the "truthiness" ofadmitted
. When set to a string,admitted
is "truthy".Gurutej Battaram
2,224 PointsGurutej Battaram
2,224 PointsI get it now. Thanks a bunch !!