What I'm trying to do is simply find and define an x and y coordinate for the highest number in the array.
For example, 50000 would output: x = 2, y = 2. Is there an easy way to accomplish this?
I created this code below:
data_array = [[0, 1, 2, 3, 50000],
[5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24]]
highest_num = data_array[0][0]
x = 0
y = 0
# looping from 0 to len(data_array)-1
for i in range(len(data_array)):
# looping from 0 to len(data_array[i])-1
for j in range(len(data_array[i])):
# checking data_array[x][y] is less than data_array[i][j]
if data_array[x][y] < data_array[i][j]:
# updating x and y
x = i
y = j
highest_num = data_array[i][j]
# printing the values of highest_num, x and y
print("highest_num =", highest_num)
print("x =", x)
print("y =", y)
But I would get x = 0, y = 4. I wanted to reference the middle of the array which is 12 and make the output be x = 2, y = 2.
Can this be accomplished without numpy where? I want the points to track with the max wherever it is.