(Python) How to find the index of the maximum value of a list?
Question: The instructions for the program: To create an empty list and fill it with 20
random integers between 1-500 inclusive, print the list on a single line, and
print the maximum value of that list on a separate line. The max value
function cannot be used.

But then it asks to print the index of the maximum value in the list. Here's
what I have so far:

    
    
    import random
    
    print()
    nums = []
    
    for num in range(20):
        nums.append(random.randint(1, 500)); sep=''
    
    max = nums[0]
    for i in nums:
        if i > max:
            max = i
    
    print(nums)
    print("The maximum value that appears in the list is " + str(max) + ".")
    

So I have the max value problem solved, but I'm having a hard time determining
how exactly to find the index of the maximum value from the list.

Any help appreciated.


Answer: Lists have a `.index` method. That should fit the bill.

    
    
    >>> ["a","b","c"].index("b")
    1
    

