How to edit console output
<p>I have the following very simple code</p>

<pre><code>stdout.write("Hello World")
stdout.write("\rBye world")
stdout.write("\rActually hello back")
</code></pre>

<p>Which prints as expected 'Actually hello back' however if i were to add a newline</p>

<pre><code>stdout.write("\n")
</code></pre>

<p>How can I go back a newline and then to the beginning of the line so I can actually just output "Hi" instead of </p>

<pre><code>Actually hello back
Hi
</code></pre>

<p>I tried</p>

<pre><code>stdout.write("\r")
stdout.write("\b")
</code></pre>

<p>However none of them seem to do the trick. The end goal is to display a big chunk of text and then update the output in real time without having to write again. How can I achieve this in python?</p>

<p><strong>EDIT</strong>
My question is different than the one suggested as I don't want to modify a single line. I want to be able to print 4-5 lines of text and then replace them in real time instead of just one line that is modified.</p>