The solution is really simple using the time
module in both Python 2 and Python 3:
import time
c=1
word = "Hello"
print(word)
l=word[len(word)-1]
time.sleep(1)
while True:
print(word+l*c)
time.sleep(1)
c+=1
Outputs:
Hello
Helloo
Hellooo
Helloooo
and so on…
Explanation:
-
import time
andtime.sleep()
are used for the 1-second delays -
print(word+l*c)
inside thewhile-loop
prints the word + the last character c times, and c increases by 1 each time the loop executes -
while True
repeats continuously until the program stops executing
Hope this helps!