What is the correct thinking about the syntax?
[] and {} or 1
Result of this code is 1
I am not sure how to explain this example.
I tried understanding [] and {}
and this return []
What is the correct thinking about the syntax?
[] and {} or 1
Result of this code is 1
I am not sure how to explain this example.
I tried understanding [] and {}
and this return []
In order of operations, and
comes before or
, so the effective statement is
([] and {}) or 1
bool([])
is False.
bool({})
is False.
Therefore, [] and {}
is []
.
Finally, [] or 1
is 1.