We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Now maxVal stores the maximum value in the array count using the function max(). In second line, we are using the method index(). The index() method finds the given element in a list and returns its lowest index. So, here it finds maxVal in the list count and stores the location of its first occurence in ans. The last line just prints ans.
Migratory Birds
You are viewing a single comment's thread. Return to all comments →
For the convenience, let's break the statement into equivalent code :
Now
maxVal
stores the maximum value in the arraycount
using the functionmax()
. In second line, we are using the methodindex()
. The index() method finds the given element in a list and returns its lowest index. So, here it findsmaxVal
in the listcount
and stores the location of its first occurence inans
. The last line just printsans
.