What I am trying to do is take a user input for as many rows as they wish, and make it into an array. After that i want to find where the highest number is in the array, an (x,y) coordinate of the number type of thing. I have created the initial array in different way but for example I have:
import numpy as np
m = []
rows = eval(input("How many rows in the list:"))
for row in range(rows):
m.append([])
value = eval(input("Enter a row:"))
m[row].append(value)
m = np.array(m)
print(m)
M = np.amax(m)
print(M)
index = np.where(M)
print(index)
The printing is just so i can see what it is doing. As a final i just want to see the last line in this example:
Enter the number of rows in the list:3
Enter a row: 1,5,6
Enter a row: 2,6,7
Enter a row: 5,26,12
The location of the largest element is at (1, 2)
Extra info: I don't care if it uses numpy of not. and i wouldn't be against using separate functions, when i think about it it might be a good idea; one to create an array and a separate to locate the largest number.
Thanks in advance.
PS. As the comment says, eval shouldn't usually be used because of security risks. The only reason I am using it is because this is a quick assignment for school.
evalto convert arbitrary user input.evalandexecshould generally be avoided because they can be a security risk. For details, please see Eval really is dangerous by SO veteran Ned Batchelder.