I have devised the following code for delaying the printing of a sentence character by character in VS Code. Here's the code for the program:-
import time
sentence = "Whats Up My buddies!"
start = time.time()
for character in sentence:
print(character, end="")
time.sleep(0.6)
end = time.time()
print("Elapsed time:", end - start, "seconds")
I tried to time my code using time.time() and the result I was getting was about 12 seconds. I also checked with another code editor but it also gave the same result.
I have expected that each character of the sentence would be printed out slowly one after another with a 0.6 second delay, but the whole sentence was printed out immediately after 12 seconds instead.