Today we are going to share a Python program to find the second largest number in a list. If you are a python beginner and want to start learning the python programming, then keep your close attention in this tutorial as I am going to share a Python program to find the second largest number in a list.
Copy the below python program and execute it with the help of python compiler.
1 2 3 4 5 6 7 | a=[] n=int(input("Enter number of elements:")) for i in range(1,n+1): b=int(input("Enter element:")) a.append(b) a.sort() print("Second largest element is:",a[n-2]) |
Enter number of elements:4
Enter element:23
Enter element:56
Enter element:39
Enter element:11
Second largest element is: 39
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.