second highest value from list in python | list in python #pythonprogramming #pythonlearning #shorts

preview_player
Показать описание
second highest value from list in python | second highest value
WAP to get second highest value from the
list without using sort function
dsts = [1,2,8,3,12]
code:
data = [1,2,8,3,12]
highest,second_higheset = 0,0
for a in data:
if not highest or a highest:
if highest:
second_highest = highest
highest = a
print("second_highest: {}".format(second_highest))
second_highest: 8
Рекомендации по теме
Комментарии
Автор

Does it work, even it contains a typo higheset?

tspark