SHARE
TWEET

Untitled

a guest Jun 25th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def largestElementIndex(lst):
  2.     x=0
  3.     maxNum=0
  4.     while x+1 < len(lst):
  5.         if lst[x] > maxNum:
  6.             maxNum=x
  7.         x+=1
  8.     return maxNum
  9.  
  10. print "Program Output"
  11. indexOfMax = largestElementIndex([1, 4, 3, 3, 2])
  12. print 'Index Of Max Value is',indexOfMax
  13.      
  14. def largestElementIndex(lst):
  15.     x=0
  16.     maxNum=0
  17.     maxIndex=0
  18.  
  19.     while x < len(lst):
  20.         if lst[x] > maxNum:
  21.             maxIndex=x
  22.             maxNum=lst[x]
  23.         x+=1
  24.     return maxIndex
  25.      
  26. def largestElementIndex(lst):
  27.     max_index = 0
  28.     max_value = lst[0]
  29.  
  30.     for index, value in enumerate(lst)
  31.         if value > max_value:
  32.             max_index = index
  33.             max_value = value
  34.  
  35.     return max_index
  36.      
  37. max_index = max(enumerate(lst), key=lambda pair: pair[1])[0]
  38.      
  39. res = lst.index(sorted(lst)[-1])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top