You now know how to create your own types. Next we're going to create two types that are related to each other. I've already defined a song class. It has an artist, a title, and a duration, measured in minutes and seconds. In addition to the constructor, there's one more method that returns the string representation of the song. At the bottom of the file, there's the little program that uses this type. It creates two songs and prints them. Now we'll define a playlist class, to keep track of a playlist of songs. We'll begin by defining the constructor, which that's the title of the playlist. Initially the playlist won't contain any songs. Let's add an example to the doc string. The title will be passed as an argument to the constructor. Initially, the playlist won't contain any songs. And we're going to use a list to represent the songs in the playlist so that list will initially be updated. To implement this we create the two instance variables, title and songs. Next we'll define an add method that will add a song to the playlist, it will have two parameters, the playlist and song. And we're going to need to use that song type that we created earlier. The song class is in song.ply. So we need to import the song module, lower case s-o-n-g. Then we need to specify that the class definition can be found in the module song. Now we've got the song, and we're going to add it to this playlist using this new method. Songs instance variable is a list. So we'll use the append method to append the song to the list. Finishing off the example in the doc string. We expect the first song in the community and artist playlist to be Stompa. Before writing any more code, let's take a moment to run the doc tests. No news means that the tests have passed. Now let's write a method called get duration. It's going to return the length of the playlist, measured in minutes and seconds. For the example, we start by creating a playlist, and then we'll add two songs to it and get the duration of the playlist. The total length of the playlist is the sum of the lengths of the two songs. So this playlist is eight minutes and 18 seconds long. We're going to use 2 accumulators, one to keep track of the total number of minutes for all songs in the play list, and another to keep track of the total number of seconds. We'll look up a song's length using it's minutes and seconds instance variables. So, for each song in the playlist list of songs we'll look up the play, that songs instance variables, minutes and seconds and add the values that they refer to to the total minutes and total seconds. After we add each songs duration to the total duration. We want to return the number of minutes and seconds, but it's not quite so simple. It's possible that when we sum the lengths of the songs in the playlist, that the total number of seconds ends up being greater than 60 Imagine that we have a long playlist, and the total number of seconds is 135. That's equivalent to two minutes and 15 seconds. If we take 135 and divide it by 60 using integer division, that gives us the 2 minute spart. And if we take 135 minus 60, that gives us the 15 seconds. Rather than simple returning total minutes and total seconds. We'll take the number of seconds, and add any full minutes to the total number of minutes. And take the remainder, which will be a value between zero and 59, and return that as the number of seconds. Last, but not least, we'll implement the __str method to generate a stream representation of the playlist. It wants the title of the playlist and its duration as well as the name of featured artist, song titles, and their durations. There may argument that what this takes is the playlist, and it returns a string. The first line of the string, it names the playlist title and its duration. So begin by calling the get duration method. That returns a couple with minutes at index zero and seconds at index one. We want a string representation of those numbers. Also, seconds could be a single digit or a double digit number. We'll use a method called r-just. To make sure that the second string will always have a length of two. If right now the number of seconds is a single digit, then a zero will be placed to the left of it, creating a 2-digit string. If this string already has a length of two, then the rjust method simply returns that string. So we'll call rjust on the second string. Now we'll start to accumulate the string representation using a result variable, and it will initially contain the title and the duration of the playlist. Next we need to add each song from the playlist, its artist, title and list duration. We can leap over each song in the list of songs. And add the string representation of the song to the playlist. We'll put a new line character before each song, so that each song's description will appear on its own line. Let's add one more thing to our string representation. We'll add the song number, so that we'll know which order the songs appear in the playlist. The variable song num will refer to the song number for the song about to be added to the string next. We'll add the song number to the string, along with the period and the space and we'll be cutting it back to the song's information. Next, we increment the song number before moving on to the next song in the list. Once we've got up the strength, we can return result. Let's put everything together and play a little program to print a playlist made up of three songs of Canadian artists. The call on print this is the string representation of the play list. So we'll see the playlist title its duration and then information about three songs on the playlist in the order that they were added to the playlist.