When Bb=[50,20,20,10,30]
the output is rank=[1,2,3,3,4,5]
how do I get this output? sort
and reverse
are written in order, but I don't know after that
rank = [1, 2, 3, 4, 5]
I don't understand what you want to express.
If you want to express Bb like 50: 1st, 20: 2nd...
You have to add the ranking by turning the for statement on the list.
Bb=[50,20,20,10,30]
Bb.sort(reverse=True)
dic = {}
for i in range(0,5):
dic [Bb[i] = str(i+1)+'etc'
print(dic)
© 2024 OneMinuteCode. All rights reserved.