My code looks like this:
print "Doing Something...",
do_some_function_that_takes_a_long_time()
print "Done"
I want it to print that statement at the top to the screen first, then do the function, and then print the "Done" line. Currently it waits until the "Done" line is executed before it prints the top part with it.
In other words, I want the pausing to occur with "Doing Something..." on the screen. How do I achieve this?
To print a string multiple times: Use the multiplication operator to repeat the string N times. Use the print() function to print the result. The print() function will print the string repeated the specified number of times.
To print on the same line in Python, add a second argument, end=' ', to the print() function call.
You have to flush the output after your first print
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With