Python 3 Script to Find Second Largest Element in an Array or List Using Sort() Method

Python 3 Script to Find Second Largest Element in an Array or List Using Sort() Method

Python 3 Script to Find Second Largest Element in an Array or List Using Sort() Method

# Python program to find largest
# number in a list

# list of numbers
list1 = [10, 20, 4, 45, 99]

# sorting the list
list1.sort()

# printing the second last element
print("Second largest element is:", list1[-2])
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment