10.2k views
1 vote
Python Activity:

We will pass in a list of numbers. Your job is to find the largest number in that list and output its index, not the actual value.
Tip: you will need to use a utility variable to store the maximum value and a decision to see if each number is bigger than the current maximum value encountered in previous iterations.
------------------------------------------------------
Required Program Output
Program Failed for Input: 1,5,8,23,78,22,0 Expected Output: 4
------------------------------------------------------
# Get our numbers from the command line
import sys
numbers= sys.argv[1].split(',')
numbers= [int(i) for i in numbers]
# Your code goes here

User Nouney
by
5.2k points

1 Answer

5 votes

Answer:

Step-by-step explanation:

def indexOfMax(lis):

m = max(lis)

indx=0

for i in range(len(lis)):

if lis[i]==m:

indx=i

break

return indx

print(indexOfMax([1,5,8,23,78,22,0]))

Python Activity: We will pass in a list of numbers. Your job is to find the largest-example-1
User Annyo
by
5.0k points