totalMean = [33, 12, 52, 51, 49, 67, 58, 98, 91, 89, 82, 79]
buckets = {limits: [] for limits in ((12, 33), (49, 52), (58, 67), (79, 98))}
for tup in totalMean:
for lo, hi in buckets:
if lo <= tup <= hi:
buckets[(lo, hi)].append(tup)
break
result = [sorted(buckets[limits]) for limits in sorted(buckets)]
print(result)
你在找这样的东西
结果如下:
希望这有帮助
听起来像是你在尝试将值按范围排序:
输出:
相关问题 更多 >
编程相关推荐