title: List_Name.clear causes crash in python
body: <p>I'm trying to create a snake algorithm that beats the game on its own, I've gone for the Hamiltonian cycle method with the capability of creating shortcuts, I was trying to create the cycle by using a pathfinding algorithm and compute the longest path where the head of the snake is the start, the tail the end and the 2 blocks in between are walls, the pathfinding library in python uses a matrix to represent the map of pixels, so to generate my matrix I use this block of code:</p>
  <pre><code>from pathfinding.core.grid import Grid
  from pathfinding.finder.a_star import AStarFinder
  from pathfinding.core.diagonal_movement import DiagonalMovement
  
  
  matrix=[]
  row=[]
  
  yi=0
  xi=0
  
  while yi&lt;800:
    if row != []:
      matrix.append(row)
      yi += 20
      row.clear()     #This causes crash
    while xi&lt;1400:
      row.append(1)
      if  xi == 40 or xi == 60:
        if yi == 20:
          row.append(0)
      xi += 20
  
  grid = Grid(matrix=matrix)
  
  start = grid.node(4, 1)
  end = grid.node(1, 1)
  
  finder = AStarFinder(diagonal_movement=DiagonalMovement.always)
  path, runs = finder.find_path(start, end, grid)
  
  print('operations:', runs, 'path length:', len(path))
  print(grid.grid_str(path=path, start=start, end=end))
  </code></pre>
  <p>But whenever I run it, it crashes,
  I've narrowed it down to the line
  <code>row.clear()</code>
  but I have no clue why it does this, if I remove it no walls are created, other methods of emptying the list like :<code>row=[]</code> or</p>
  <pre><code>while i&lt;len(row):
       row.remove(i)
       row += 1
  </code></pre>
  <p>give me the same result, I get no error message, nothing prints it just crashes, its even more clear on the entire code because the window displaying the game of snake doesn't display anything and the windows crash window appears, I'm using Windows 10, python 3.8.2</p>
  <p>I'm quite new to programming so please excuse my inefficient code, I do it for fun and performance brings me little pleasure, any help is greatly appreciated</p>
  <p>I hope I didn't miss anything obvious making you waste time but as long as my code is fixed I'm a happy chappy.</p>
  <p>Thanks</p>