I would like to create a maxValues โโlist containing the top 20 values โโfrom the list of integers lst.
maxValues = [] for i in range(20): maxValues.append(max(lst)) lst.remove(max(lst))
Is there more compact code to perform this task or even a built-in function?
source share