Код: Выделить всё
def numbers(nums):
n = nums
# 1,2,3,4,5
counts = {}
newL = list()
newVal = 0
for j in range(len(n)):
if n[j] not in counts:
counts[n[j]] = 0
newL = list(counts.keys())
print(newL)
for i,k in counts.items():
cur = i
for m in newL:
if cur > m:
counts[cur] += 1
else:
pass
val = list(counts.values())
return val
l = [7,7,7,7,7,]
print(numbers(l))
- -> [3, 0, 1, 2]
Код: Выделить всё
[8, 1, 2, 3] - -> [0]
Код: Выделить всё
[7]
- -> [0, 0, 0, 0, 0]
Код: Выделить всё
[7, 7, 7, 7, 7] - -> [0, 1, 1, 2] (ранг с меньшим значением)
Код: Выделить всё
[1, 2, 2, 3]
Подробнее здесь: https://stackoverflow.com/questions/798 ... -duplicate