Good morning, please I have a table that I'm trying to return the positions (ranks) of students scores. I have searched everywhere and I'm not getting anything better. I thought I could do it with sorting but that's not the case. This is the table:
Name Score Position
David 89 3rd
James 56 5th
Matt 72 4th
John 91 1st
Iva 56 5th
Anna 91 1st
I tried writing this code but it's not taking care of the duplicates
score = [89, 56, 72, 91, 56,91]
order = sorted(list(set(score)), reverse=True)
position = []
for n in score:
position.append(order.index(n) + 1)
print(position)