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 trial

Python Python Basics (2015) Logic in Python Conditional Value

Can someone direct me to the video as to how to set/change a variable using the result of conditional/s?

Im not seeing how to have a variable's data modified using the result of a conditional. Im sure its probably a compilation of previous video's, but Im not finding which ones

-thanks

conditions.py
admitted = None
age= 25
if age >= 13:
  print(admitted is admitted)

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

I don't know that there's a specific video about exactly that because setting the value of a variable based on a condition is the same as setting the value of a variable anywhere else. In fact, it was already done at the beginning of your code twice. Once with admitted and once with age. But here's an important point... you don't get to determine the age. They're going to determine it for you. So don't set the age yourself. Take a look at what you need.

admitted = None
if age >= 13:
  admitted = True

And use this same logic for step 2. Happy coding!

Ahhh, Thank you so much I was under the notion that conditional results only allowed print statements determine what shows up. But step by step yes? Thanks again!

Carlos Federico Puebla Larregle
Carlos Federico Puebla Larregle
21,073 Points

In the code challenge, it says to you that the variable named "age" is going to be created for you so you don't need to create that variable. And is not asking for you to print the admitted variable, you just have to assign the boolean value "True" to the variable "admitted" if the "if condition" passes. You could do it like this:

admitted = None
if age >= 13:
    admitted = True

I hope that helps a little bit.

Thanks so much for the clarification!!!