TypeError: list indices must be integers or slices, not float im getting this error.. The question is to find the median of the 2D array

arr2D =
n = int(input(“enter length”))
x = 0
for row in range(0,n):
row1 =
for col in range(0,n):
row1.append(int(input(“enter a number”)))
for count in range(0,n):
x = (n + 1)/2

Division returns a float, so either convert x to an int or use integer division (//).

Hi Vedanshi and welcome. For future posts please read the pinned thread so that you can post code that has proper formatting - that lets us read the code properly and be sure of what it actually says (including indentation).

However, this is a simple and common issue that’s exactly as @moosemaimer said. Here’s a more in-depth reference, too: