+ 9

[SOLVED] loading bar in python

so, I made this code a day ago, and it works great. but.... I was wondering. can I make it so that instead of making a bunch of loading bars and printing them all out. it would just make one loading bar and update it. this is the code i have https://code.sololearn.com/clVxw7CCrQW4/?ref=app

25th Oct 2018, 10:35 PM
LONGTIE👔
LONGTIE👔 - avatar
9 Answers
+ 9
In a console, you can use a carriage return (\r). Instead of jumping to the next line, you go back to the beginning of the current line and overwrite/update it. I've done it, works perfectly. And it's platform independent /Edit: Here's an example code https://code.sololearn.com/c4qL4yxM316Z/?ref=app
26th Oct 2018, 5:21 AM
Anna
Anna - avatar
+ 8
Nafis Handoko that would only work if I ran my code in the command line right?
26th Oct 2018, 3:15 AM
LONGTIE👔
LONGTIE👔 - avatar
+ 6
How about GUIing it? (won't work in SL, but at least it works somewhere)
26th Oct 2018, 3:26 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
Emerson Prado can you provide a example, I don't think I fully understand.
26th Oct 2018, 3:13 AM
LONGTIE👔
LONGTIE👔 - avatar
+ 2
LONGTIE👔 With Sololearn's code playground, it won't work... Wait, your loader won't work under any circumstance, even with a proper IDE. Reason being you can't clear your console.
25th Oct 2018, 11:27 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
does python not have a cmd function to clear the console like os.execute(#cmd here)
25th Oct 2018, 11:37 PM
Yusuf
Yusuf - avatar
+ 2
to clear the console os.system ("cls")
26th Oct 2018, 1:16 AM
Nafis Arinda Rizky Putra Handoko
Nafis Arinda Rizky Putra Handoko - avatar
+ 2
You could just output one char at a time, for every whatever percentage of completion. Like print with "" as line ending. Caveat 1: won't work in SoloLearn playground Caveat 2: you can't print anything else until your progress bar is finished. Ah, remember to print a newline when bar finishes.
26th Oct 2018, 3:11 AM
Emerson Prado
Emerson Prado - avatar
26th Oct 2018, 8:24 PM
Zubair Khan
Zubair Khan - avatar