Python : Find Second largest number in a given list

preview_player
Показать описание
Python program to find the second largest number from a given list
Conditions : Without using remove(), set(), max(), sort() i.e without using built-in library functions
and without using the sorting algorithms
Рекомендации по теме
Комментарии
Автор

Thank you for sharing the logic, But it fails for some of tests like below, please check and rectify it.
1. [ 20, 18, 19, 3, 6, 7, 8] - returned value is 20 but expected 19
2. And what if all elements in list are equal, like [5, 5, 5, 5, 5]

shankarhogalennavar
Автор

why add 0 next to list2? and what happened to list1 as parameter in function ret_snd_largVal?

Cloudxxx
Автор

by using if elif/else have to find 2nd largest number among 4 numbers . can u help me how to write pls.

Svithasisters