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 trialDarren Taylor
1,052 PointsConditional value challenge... Please help me solve this task, I'm totally confused!
I'm totally confused with this question as I don't understand what they want me to do. Can someone please clarify the question and give some examples, thanks?
The question reads:
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.
admitted = None
if age < 13
print(admitted = False)
age = 14
if age > 13
print (admitted = True)
3 Answers
Alexandra Barnett
Front End Web Development Techdegree Graduate 46,473 PointsHi Darren! admitted is just a variable name:
my_dog = "Charlie"
a_car = "Red"
admitted = False
am_hungry = True
All these are names that we make up that have values assigned to them. admitted is just one of those made up names to hold a boolean value in (a true or false value). Sometimes, when we want to make a new variable, we don't always want to give it a value at the beginning. This is where the None comes from, it's a way of saying, "I am making this variable, it will have a value in the future but I don't want it to have a value right now". Then, with the conditional statement, we are giving admitted a value.
There is documentation at python.org: https://www.python.org/doc/
Although sometimes documentation can look daunting at the beginning, the more you look at it the easier it will become. The best thing when you don't understand something is to google it or, of course, ask on here :). I do that all the time and you normally find that someone else has had the same problem.
I hope that helps a bit more - again, let me know if you have any more questions :).
Alexandra Barnett
Front End Web Development Techdegree Graduate 46,473 PointsHi Darren! So, firstly, you don't need to assign age = 14 because the age variable has been made (behind the scenes). Secondly, you don't need to print the admitted - just set it equal to either True or False. You can also either set age >= 13 or > 12 if you want as well :) I've put mine below:
admitted = None
if age >= 13:
admitted = True
else:
admitted = False
Hope this helps! Let me know if you have any questions :)
Darren Taylor
1,052 PointsThanks for your help…! But unfortunately, I’m still trying to comprehend the terminology such as “admitted.” This word hasn’t been mentioned before in this course so I’m bound to get stuck. Does Treehouse have educational documents other than the videos because that alone doesn’t seem to cover everything mentioned in the challenges?
Jayden Hassan
3,099 PointsTHANK YOU SOOOOOOOOOO MUCH, I HAVE BEEN STUCK ON THIS FOR A GOOD 3 WEEKS
Sorry for to much caps
Marcus Larsson
1,768 Pointsadmitted is just a variable. Could have been called anything. All your doing is changing the bool of the variable
Darren Taylor
1,052 PointsThanks for info Marcus.
Darren Taylor
1,052 PointsDarren Taylor
1,052 PointsHi Alexandra, I think you’ve clarified everything for me and have given me constructive advice too. Thank you for sharing these essential Python resources with me, this will definitely help me throughout my studies, your help and response has been excellent. Thank you