Ex. 40 arguing with arguments

I revisited exercise 40 after thinking my brain started to understand OOP a bit better.
But now I’m extra confused.

What I don’t get is why there is no error in the below. Does Song([“Happy birthday to you”, “I don’t want to get sued”, “So I’ll stop right there”]) not pass tree arguments? Whereas def init(self, lyrics2): only takes 1 argument?

class Song(object):

    def __init__(self, lyrics2):
       self.lyrics = lyrics2

    def sing_me_a_song(arg):
        for line in arg.lyrics:

happy_bday = Song(["Happy birthday to you", "I don't want to get sued", "So I'll stop right there"])


The output is:
Happy birthday to you
I don’t want to get sued
So I’ll stop right there

Where does the code chop the comma separated text snippets into lines?

Hello @ktrager

Hopefully I can give you a useful answer on this one too.
The __init__ only takes one parameter (lyrics2).
When the class is instantiated a list provided as argument.

It is the method (sing_me_a_song) that splits it up to three lines with the for loop.


Thanks @ulfen69

Got it - think I didn’t see the words came as a whole list…
It then makes sense that the text comes as one package in the form of a list and then the for-loop loops through each item in the list.