title: TypeError: 'float' object is not subscriptable in 3d array
body: <p>guys I'm trying to write a function which get a 3-D array and check how many of its cells are empty. 
  but i will got the following error</p>
  
  <pre><code>in checkpoint
  if m[i][j][0] == 0:
  TypeError: 'float' object is not subscriptable
  </code></pre>
  
  <p>my function is as following</p>
  
  <pre><code>def checkpoint(m, i, j):
      c = 0
      if m[i][j][0] == 0:
          c += 1.0
      if m[i][j][1] == 0:
          c += 1.0
      if m[i][j][2] == 0:
          c += 1.0
      if m[i][j][3] == 0:
          c += 1.0
  return c
  </code></pre>
  
  <p>its from a large module that I'm working with 
  here is the function that work with it </p>
  
  <pre><code>def check(m, size):
  flag = 2
  for i in range(size):
      for j in range(size):
          print(i, j, "/n")
          c = checkpoint(m, i, j)
          s = summ(m, i, j)
          if c == 2:
              if s == 2 or -2:
                  flag = 1.0
                  if m[i][j][0] == 0:
                      if m[i][j][1] == 0:
                          m[i][j][0] = m[i][j][1] = (-s/2)
                          fix(m, i, j, 0, size)
                          fix(m, i, j, 1, size)
                      elif m[i][j][2] == 0:
                          m[i][j][0] = m[i][j][2] = (-s/2)
                          fix(m, i, j, 0, size)
                          fix(m, i, j, 2, size)
                      else:
                          m[i][j][0] = m[i][j][3] = (-s/2)
                          fix(m, i, j, 0, size)
                          fix(m, i, j, 3, size)
                  elif m[i][j][1] == 0:
                      if m[i][j][2] == 0:
                          m[i][j][1] = m[i][j][2] = (-s/2)
                          fix(m, i, j, 1, size)
                          fix(m, i, j, 2, size)
                      elif m[i][j][3] == 0:
                          m[i][j][1] = m[i][j][3] = (-s/2)
                          fix(m, i, j, 1, size)
                          fix(m, i, j, 3, size)
                  else:
                      m[i][j][2] = m[i][j][3] = (-s/2)
          if c == 3:
              flag = 1.0
              if m[i][j][0] == 0:
                  m[i][j][0] = -s
              elif m[i][j][1] == 0:
                  m[i][j][1] = -s
              elif m[i][j][2] == 0:
                  m[i][j][2] = -s
              else:
                  m[i][j][3] = -s
  return m, flag
  </code></pre>
  
  <p>any comment would be appreciated</p>
  
  <p>update:</p>
  
  <p>i desperately run the function inside the module and i saw that there isn't any problem whit first iteration and second iteration of the i and j in check function. but after that will faced with the error.</p>
  
  <p>here is my output:<a href="https://i.stack.imgur.com/CV7xS.png" rel="nofollow">the output of the code that I'm trying to run</a></p>
  
  <p>as you can see it didn't have any problem in first iteration of the i in check function.<br>
  here is my fix function. it changes some other cells with respect to the arrow that cell that just changed.</p>
  
  <pre><code>def fix(m, i, j, k, size):
  ip = i - 1
  jp = j - 1
  iz = i + 1
  jz = j + 1
  if ip &lt; 0:
      ip = size - 1
  if jp &lt; 0:
      jp = size - 1
  if iz &gt; size - 1:
      iz = 0
  if jz &gt; size - 1:
      jz = 0
  kp = (k+2) % 4
  if k == 0:
      m[i][jz][kp] = -1 * m[i][j][k]
  if k == 1:
      m[iz][j][kp] = -1 * m[i][j][k]
  if k == 2:
      m[i][jp][kp] = -1 * m[i][j][k]
  if k == 3:
      m[ip][j][kp] = -1 * m[i][j][k]
  return m
  </code></pre>
  
  <p>here you can find whole package:
  <a href="https://codeshare.io/dsT8l" rel="nofollow">my code</a></p>