29. Problem to find the second largest number in the list.  

In this program, we will take a user input as a list. Find the second largest number from the list with the help of the below-given steps.

Second largest number in a list:

Steps to solve the program
  1. Take a list as input.
  2. Sort the list using sort().
  3. Print the second largest number from the list using indexing.
				
					#Input list
list1 = [22,11,78,45,90,44]

#sorting the list
list1.sort()

#printing the output
print("2nd largest number: ", list1[-2])
				
			

Output :

				
					2nd largest number:  78
				
			

Related Articles

Generate all sublists with 5 or more elements

Find the second smallest number from the list

Leave a Comment