Given a list of numbers, there are inbuilt functions that can given you the minimum or maximum elements in a list. However, what if you wanted to find out the nth largest of smallest number ?
Let’s take an example. Say we have a list of numbers like so
[9, 4, 9, 3 , 5, 7, 2]
If we wanted to find out the second largest number, it would be 7. The third largest number would be 5. Similarly, the third smallest number is 4.
Create a function nth_number(numbers, n, large_small) that takes in 3 arguments.
numbers– The list of numbers
n – The nth number
large_small – A string with a value of “small” or “large”
For example, nth_number(list, 3, “small”) would return the 3rd smallest number in the list.
Courses - https://www.udemy.com/course/just-eno...