-3

I want to print out the nth value of the the maximum number within a list

list_= [1,3,2,2,8,11,4]
max_val = max(list_)

Expected output

The maximum value of 11 is at the 6th place from the start of the order
  • 1
    See the `index` method. – Tumbleweed53 Dec 21 '20 at 01:00
  • 1
    `list_.index(max(list_))` index => `list_.index(max(list_)) + 1`th place. – ssp Dec 21 '20 at 01:01
  • 1
    Does this answer your question? [Pythonic way to find maximum value and its index in a list?](https://stackoverflow.com/questions/6193498/pythonic-way-to-find-maximum-value-and-its-index-in-a-list) – ruancomelli Dec 21 '20 at 01:04
  • `index` unnecessarily loops through the list twice. Refer to the answers on the linked post for faster answers. – Aplet123 Dec 21 '20 at 01:04
  • @Aplet123 @Escualo's answer in the given link seems to suggest the explicit usage of `index` is just as fast if not faster. – ssp Dec 21 '20 at 01:24

1 Answers1

0

Take index of max value in the list

list_.index(max(list_))
Anjaly Vijayan
  • 237
  • 2
  • 9