How do I print a word on a line, and after every second it prints the word with one extra letter on the end of it every time

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 and time.sleep() are used for the 1-second delays

  • print(word+l*c) inside the while-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!

Leave a Comment