Python: Third largest number from a list of numbers using set
29. Find Third Largest Number Using a Set
Write a Python program to find the third largest number from a given list of numbers.Use the Python set data type.
Sample Solution:
Python Code:
Sample Output:
Original list of numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9] Third largest number of the said list of numbers: 7 Original list of numbers: [1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 10] Third largest number of the said list of numbers: 8 Original list of numbers: [1, 2, 3] Third largest number of the said list of numbers: 1 Original list of numbers: [1, 2, 2] Third largest number of the said list of numbers: None Original list of numbers: [1, 2] Third largest number of the said list of numbers: None
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to convert a list to a set to remove duplicates and then find the third largest number.
- Write a Python program to sort the unique elements of a list and extract the third largest value using negative indexing.
- Write a Python program to use heapq.nlargest on a set derived from a list to get the third largest number.
- Write a Python program to implement a function that returns the third largest unique element from a list, or an error if not enough elements exist.
Go to:
Previous: Combine three numbers to get the target number.
Next: Return unique strings from a list of strings.
Python Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.