(Optional) Introducing a delay

Something to note about the code that we just made is that it does print out all the lyrics of the song, but it does so in a rather quick fashion. Something that is useful in scenarios like this is to introduce a delay into our code. We can do this with the time.sleep() function, but we will first need to import the time library to do so. Put simply, a library is a collection of code and functions that someone else has made, that we can use.

Before we can use a library, we need to tell our code we want to use it with the import keyword. We can place this anywhere in the code, but it is most common to place any import lines at the beginning of the file, so we are going to make the first line of our code as follows, and make sure that you just move all other code downward. (most code has been left out of the example on the right)

import time

container = input(...)

Now, it’s simply a matter of placing time.sleep() anywhere that we would like for there to be a pause. The number we place in the parenthesis is the number of seconds our program will pause for. In our code, we will want to place a time.sleep() statement after each print statement, so it feels more song-like, like the snippet of code that follows

    print(str(on_the_wall) + container + " of " + filling)
(more code...)

Continue through your program, adding time.sleep() statements after each print statement