This is the assignment on Codio. I am new to programming and don't know what to do here.
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.
# 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
So, first, you have to send the values through command line, like this:
This is the code:
First, you have to find the max value:
Then, you just need to locate where that value is:
So the output will be:
4Remember, it's 4 and not 5 because in Python, array indexes start at 0.
Edit:
In case you are not allowed to use the
indexfunction:Of course, the easiest way is this: