Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to find index of second largest number in array python

>>> fr = [8,4,1,1,12]
>>> n = 3
>>> result = [fr.index(i) for i in sorted(fr, reverse=True)][:n]
>>> print(result)
[4, 0, 1]
Comment

PREVIOUS NEXT
Code Example
Python :: python find location of module 
Python :: converting datetime object format to datetime format python 
Python :: scoop bucket add extras 
Python :: rightclick in pygame 
Python :: pandas find basic statistics on column 
Python :: python pandas convert comma separated number string to integer list 
Python :: python ssh library 
Python :: set axis plt python 
Python :: python format decimal 
Python :: python opens windows store 
Python :: python pandas dataframe from csv index column 
Python :: jsonresponse status code django 
Python :: python moving average time series 
Python :: print hello world python 
Python :: how to sort values in python from dictionary to list 
Python :: python zfill 
Python :: python print int in string with zero padding 
Python :: how to add row in spark dataframe 
Python :: remove blank spaces from a list python 
Python :: python list all files in directory 
Python :: max of matrix numpy 
Python :: merge multiple csv files 
Python :: is prime in python 
Python :: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. 
Python :: how to increase bar width in python matplogtlib 
Python :: how to use prettytable with python 
Python :: how to fill nan values with mean in pandas 
Python :: read pdf py 
Python :: hotkey python 
Python :: get a list of ids from queryset django 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =