title: Replace multi-line string in terminal
body: <p>I am trying to write some code which will overwrite its previous output e.g. the original output is <code>&quot;1&quot;</code> but the <code>&quot;1&quot;</code> is replaced with a <code>&quot;2&quot;</code>. This makes it look as though the <code>&quot;1&quot;</code> had never been outputted in the first place.
  I have a list of lists called <code>board</code>, I convert this list into a multi-line string using this code:</p>
  <pre><code>rendered_board = &quot;&quot;
  for y in range(board_height):
      for x in range(board_width):
          rendered_board += board[y][x]
  
      rendered_board += &quot;\n&quot;
  </code></pre>
  <p>I get the string I want, However, I want to be able to update this string with a new one and have it replace the old.</p>
  <p>Example output :</p>
  <pre><code>+-------+                      +-------+
  |       |  *gets replaced by*  |       |
  |       | -------------------&gt; |   *   |
  |       |                      |       |
  +-------+                      +-------+
  </code></pre>
  <p>Currently I have been trying to do this by using <code>end=&quot;\r&quot;</code>
  e.g.</p>
  <pre><code>print(rendered_board, end=&quot;\r&quot;)
  update_board()
  print(rendered_board, end=&quot;\r&quot;)
  </code></pre>
  <p>This has resulted in this output:</p>
  <pre><code>+-------+
  |       |
  |       |
  |       |
  +-------+
  +-------+
  |       |
  |   *   |
  |       |
  +-------+
  </code></pre>