Open this example in the interactive library
Source code
from collections import Counter
readings = [3, 9, 11, 18, 22]
print(sorted(Counter(n // 10 * 10 for n in readings).items()))Sample output
[(0, 2), (10, 2), (20, 1)]

Open this example in the interactive library
from collections import Counter
readings = [3, 9, 11, 18, 22]
print(sorted(Counter(n // 10 * 10 for n in readings).items()))[(0, 2), (10, 2), (20, 1)]