2
I have the list [5, 7, 2]
. I need to create another list containing the indexes in this list, ordered so that the first index corresponds to the largest element in the list, the second corresponds to the second largest and so on - i.e., [1, 0, 2]
.
I could only show one number on the list at a time:
Index : 1
Numbers: 7
What I don’t understand is how to ride the for
to display the indexes and their values.
lista = [5, 7, 2]
ind_num = lista.index(max(lista))
print('Maior elemento: ',max(lista))
print('Indice: ', (ind_num))
Luke, could you be clearer? Each element of a list (which I believe should be your case, has its own index, starting from scratch). Edit: I understood your case, I will elaborate the answer.
– zangs
The elements of a list are their values per list = [5, 7, 2], the elements of this list are 5, 7, 2 and their incidence starting with 0 or the largest are in indices 1, 0, 2
– lucas