Tuples without dictionaries
Solution 1:
Try this
def histogram(s):
hist = []
for i in range(21):
hist.append(len([x for x in s if x >= i and x < i+1]))
return tuple(hist)
s = [11.3, 16.1, 7.5, 4.3, 12.4, 10.3, 18.7, 9.3, 18.5]
print(histogram(s))
Output:(0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 2, 0, 0)