3 ms·
This doesn't work because the if statement is a statement. Statements don't evaluate to anything in Python, so you can't assign it to x.
by __mharrison__ 2y ago
This doesn't work because the if statement is a statement. Statements don't evaluate to anything in Python, so you can't assign it to x.
- 8n4vidtmkvmk 2y agoHence "make it an expression"
- otabdeveloper4 2y agoIt's way to late to fix the "statement vs expression" bug in Python's design. We could have done that in the v3 switch, but we decided to spend man-centuries of effort on chasing already deprecated legacy Windows Unicode semantics instead.