What's wrong with this Python code?


-sharpencoding:utf-8
class Bird:
    def __init__(self):
        self.hungry=True

    def eat(self):
        if self.hungry:
            print (" aaah..")
            self.hungry=False
        else :
            print ("no ,thanks")



class SongBird(Bird):
    def __init(self):
        Bird.__init__(self)
        self.sound = "Squak!"

    def sing(self):
        print(self.sound)


if __name__=="__main__":
    sb=SongBird()
    -sharp["_SongBird__init", "__doc__", "__init__", "__module__", "eat", "hungry", "sing"]
    print (dir(sb))
    sb.sing()
    sb.eat()

error prompt:

AttributeError: SongBird instance has no attribute "sound", prompt has no sound attribute

Feb.28,2021

because it's _ _ init__ instead of _ _ init < del > ha < / del > you're missing two underscores < del > serious < / del >.


use super

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea7ca8-1e84.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea7ca8-1e84.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?