DEV Community

Discussion on: 18 Python one-liners that will speed up your coding process.

Collapse
 
salabim profile image
salabim

Example 2 can be written more compact:
print("no", "maybe", "yes")[(x < 42) -(x > 42) + 1]
, which is arguably easier to read.