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 Types and Branching Comparing values

Ethan Martin
PLUS
Ethan Martin
Courses Plus Student 1,883 Points

answer = 3.14 <= 3.14 -> Why is this true?

answer = 3.14 <= 3.14

I get that 3.14 is <= 3.14

However, isn't this a bool statement? Wouldn't this be evaluated as... "answer = 3.14" is false -> "False <= 3.14" is false.... right? Where is the error in my thinking

Thank you for all the help guys!

1 Answer

Everything to the right of the assignment operator (equal sign) gets evaluated before it is assigned to the variable.

So, here we first evaluate:

3.14 <= 3.14

Which is True. Python takes that True and then does something like:

answer = True

Let me know if this helps here

Ethan Martin
Ethan Martin
Courses Plus Student 1,883 Points

Thank you! I should have realized "answer" was a variable. Not a string that is being compared to the other values