I'm trying to make a message that appears when exiting the program. What I want it to look like is like this:
-
1. print the word "Quitting"
-
2. repeat 3 times:
-
- halt for 0.5 seconds
-
- print a dot in the same line with the word "Quitting"
The code:
print("Quitting", end='')
for i in range(3):
print('.', end='')
time.sleep(0.5)
print('\n')
CodePudding user response:
This appears to be a duplicate, but code works if you do it like this:
import time
print("Quitting", end='')
for i in range(3):
print('.', end='', flush=True)
time.sleep(0.5)
print('\n')
CodePudding user response:
Answer:
import time
print("Quitting", end='', flush=True)
for i in range(3):
print('.', end='', flush=True)
time.sleep(0.5)
print('\n')