r/PythonLearning • • 18d ago

What do you guys think?

Post image

I made a program that finds the second largest digit in a list.

Using the list method "remove()" and "max" function. Python is COOL!

88 Upvotes

58 comments sorted by

View all comments

0

u/Inevitable-Study502 18d ago edited 17d ago

thats a little bit destructive

numbers=[10, 54, 3, 21]
import heapq
print(heapq.nlargest(2, numbers)[1])

1

u/Strong_Essay1176 17d ago

Really? You need import got that?