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



I'm trying to understand exactly what the code is asking?

x = 4 y= 2 if not 1 + 1 == y or x == 4 and 7 == 8: print("Yes") elif x > y: print("No")

I'm confused about what an "if" statement is asking of a Boolean.

1 Answer

Steven Parker
Steven Parker
229,005 Points

This looks like a test of your understanding of operator associativity.

The "not" part of this expression just inverts the result of the comparison "1 + 1 == y" so the entire thing means "if y is not equal to 2".

Everything after the "or" in the larger expression is meaningless since 7 will never equal 8.

Great explanation! that gives me much more clarity. Whenever the code can be "translated" that helps every time. thanks!