79711080

Date: 2025-07-22 21:42:05
Score: 0.5
Natty:
Report link

I'm surprised no-one suggested bisect:

from bisect import bisect

def get_level_of_aqi(aqi):
    return bisect([0, 51, 101, 151, 201, 301], aqi)

It strikes me as more elegant and readable than any other solution, and exactly the sort of thing bisect is intended for.

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: TruffMonk