Advertisement
IT45200

largest second number

Mar 29th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. def start(lst):
  2.     for j in range (0,len(lst)-1):
  3.         if int(lst[j]) > int(lst[j+1]):
  4.             lst.insert(len(lst)-1,lst.pop(j))
  5.             start(lst)
  6.     return lst[-2]
  7.                
  8. def second_largest_item(my_list):
  9.     x = start(my_list)
  10.     print('\n\t=> second largest item = ' + str(x) + '\n')
  11.        
  12. second_largest_item([ 4,61,72,2,5,85,3,1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement