How to get the top 3 largest values from a list in Python

1 Answer

0 votes
lst = [12, 98, 80, 50, 88, 35, 70, 60, 97, 85, 89]

top3 = sorted(zip(lst), reverse=True)[:3]

print(top3[0][0])
print(top3[1][0])
print(top3[2][0])




'''
run:

98
97
89

'''

 



answered Jun 10, 2021 by avibootz

Related questions

2 answers 179 views
1 answer 169 views
1 answer 181 views
1 answer 133 views
1 answer 156 views
1 answer 140 views
...