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

bruce leong
bruce leong
2,521 Points

Making a variable true

I'm trying to make "admitted" return True if the condition is met. Why is this not working? The if condition is met as it's greater than 13, and i'm telling the variable to become True.

conditions.py
admitted = None
age = 14 

if age >= 13:
    admitted == True

1 Answer

Greg Kaleka
Greg Kaleka
39,021 Points

Hi Bruce,

There's an important difference between = and ==.

  • = is the assignment operator, meaning you use it to assign values to things. It's actively changing something.
  • == is the comparison operator, meaning it checks to see if the thing on the left is equal to the thing on the right, and returns a boolean. It's not changing anything - instead, it's asking a question. "Are these things equal?"

When you write admitted == True, you're asking the question "Is admitted equal to True". That's not what you want. You need to actively set the value of admitted to True.

Make sense?

Cheers :beers:

-Greg