+ 2
how to find 2nd largest no. in python
3 Respostas
+ 4
l = [1, 2, 3, 4, ]
print(sorted(l)[-2]) # 3
+ 1
https://code.sololearn.com/ca1cf1dYZ8PW/?ref=app
I wrote this code a few days ago to find out the second largest no.
+ 1
Prakhar Your code prints 3 for 3, 69, 285... You're not comparing numbers (1 < 2 < 15), but strings which are compared lexicographically ('1' < '15' < '2')...