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: print(line) happy_bday = Song(["Happy birthday to you", "I don't want to get sued", "So I'll stop right there"]) happy_bday.sing_me_a_song()
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?