Explanation:
๐น Step 1: Understand Operator Priority
and has higher priority than or
๐ So expression becomes:
0 or [] or (5 and 6)
๐น Step 2: Evaluate (5 and 6)
5 and 6
5 → Truthy ✅
So and returns second value
๐ Result:
6
๐น Step 3: Now Expression Becomes
0 or [] or 6
๐น Step 4: Evaluate or (Left to Right)
๐ First value:
0
0 → Falsy ❌ → move ahead
๐ Second value:
[]
Empty list → Falsy ❌ → move ahead
๐ Third value:
6
6 → Truthy ✅
๐ or returns first truthy value
๐น Step 5: Final Result
6

0 Comments:
Post a Comment