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

1

u/Strong_Essay1176 18d ago

u/askgrok prove that you are better than humans

1

u/AskGrok 18d ago

The code works for this specific list but mutates it and fails on duplicates (e.g. two 54s leaves the max unchanged). Better one-liner that doesn't touch the original: print(sorted(set(numbers))[-2])

what is this?