One way to find the kth largest number in a list is to sort the list in descending order and then return the element at index k-1.
Here's an example implementation:
main.py116 chars4 lines
Let's test it with a sample list:
main.py87 chars4 lines
In this example, the 3rd largest number in the list [10, 5, 8, 3, 2, 7, 1] is 7. The function returns 7 as expected.
gistlibby LogSnag