Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Last answered:

16 Dec 2022

Posted on:

15 Dec 2022


Error in Self.vaccination.append(vaccine)

class Patient(object):
    ''' This is something which I forgot '''

    # status = "patient"
    def __init__(self, name, age): = name
        self.age = age
        self.conditions = []
    def get_details(self):
        print(f"Patient Record: {} ,{self.age} Years Current Information: {self.conditions}.")

    def add_info(self, information):

class Infant(Patient):
    # vaccination =[]    -- Without this throwing error but not in lecture tutorial

    def __int__(self, name, age):
        self.vaccination = []
        super().__init__(name, age)

    def add_vac(self, vaccine):

    def get_details(self):
        print(f"Patient record: {},{self.age} "
              f"Patient condition: {self.conditions} "
              f"Patient has had {self.vaccination} "
              f"\n{} is an infant, has he had all his checks?")

archie = Infant("archie", 4)

Traceback (most recent call last):
  File "C:\Users\ASUS\PycharmProjects\Python365\", line 301, in <module>
  File "C:\Users\ASUS\PycharmProjects\Python365\", line 291, in add_vac
AttributeError: 'Infant' object has no attribute 'vaccination'

Both code and the error attached code seems identical with Gliss notebook but getting an error (solution I knew too i.e declaring Vaccine variable on Class level
but why??)

1 answers ( 0 marked as helpful)
Posted on:

16 Dec 2022


Hey Mayank,

Thank you for reaching out!

Inside the Infant class, the __init__ function is misspelled as __int__. That's what causes the trouble.

Kind regards,
365 Hristina

Submit an answer