Could someone help me with ex40 please?

I keep getting this error message;

“File “ex40.py”, line 12, in
“So I’ll stop right there”])
TypeError: Song() takes no arguments”

But can’t see any coding errors or mistake - Any ideas? Ex40 code below and thanks in advance;

class Song(object):

def _init_(self, lyrics):
    self.lyrics = lyrics

def sing_me_a_song(self):
    for line in self.lyrics:
        print(line)

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

bulls_on_parade = Song([“They rally around tha family”,
“With pockets full of shells”])

happy_bday.sing_me_a_song()

bulls_on_parade.sing_me_a_song()

1 Like

Hi @RMK

I copied your code and tried on my laptop.
I got other errors than you.
But I found that init just got one underscore ( _ ) on each side. There should be two.
The other could be a formatting error when I copied from the forum and pasted into vim.
The double quote around the song text didnt worked in my code. If I put a single quote around it it started to work.

([ ’ “They rally around tha family”,
“With pockets full of shells” ’ ])

See if these changes get your code working.

2 Likes

Thanks @ulfen69 it took me a while to realise that _ and __ are different!! Obvious now and everything works. Thank you