How to overwrite prints in Python? [SOLVED] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to overwrite prints in Python? [SOLVED]

https://code.sololearn.com/cwzfyyANf2r3/?ref=app In this code , the output is: Loading. Loading.. Loading... and so on. But I want the new output to replace the previous one , mimicking the "Loading" just like done in various softwares. PS: I haven't added time.sleep() because SoloLearn cannot run code with such commands. Any help?

12th Jul 2019, 7:09 PM
Ayush Gupta
Ayush Gupta - avatar
3 Answers
+ 2
Sorry for replying late. Here it is! https://code.sololearn.com/cwzfyyANf2r3/?ref=app
31st Jul 2019, 12:03 PM
Ayush Gupta
Ayush Gupta - avatar
+ 3
When it comes to the Sololearn code playground, you can't clear the output as it will only print things to the console once. However, if you're using an interactive console, you should be able to do it by using the os module and the cls function. Here's a code I put together that seems to work okay when you run it through Pydroid (although, it isn't necessarily a loading screen as it's not running while loading everything, but more just gives off the illusion that it's doing that) https://code.sololearn.com/cI2fGN0z4rAT/?ref=app
12th Jul 2019, 7:47 PM
Faisal
Faisal - avatar
+ 3
First, Sololearn doesn't allow you to show something get printed in order; it prints something all at once. Second, I don't know how to do this with Python but I can prob do this in C++.
12th Jul 2019, 8:23 PM
CeePlusPlus
CeePlusPlus - avatar