title: How to create an additional attribute in the subclass in python?
body: <p>I would like to include an additional attribute to the subclass. I have generated a class Plant. Now I am going to create a Plant_w_ID class which is a derived subclass of Plant. The Plant_w_ID class should include an addition attribute, plant_id, that holds the identifier of each plant. The plant identifier can be passed as an argument to the creation function, e.g. plant =Plant_w_ID('P1') . </p>
  
  <p>I also need to define a 'getter' method in the Plant_w_ID class to retrieve the value of ID attribute accordingly.</p>
  
  <p>May I know how to </p>
  
  <p>i) include an additional attribute, plant_id, to the Plant_w_ID class</p>
  
  <p>ii) and I don't know how to pass the plant identifier as an argument to the creation function. plant = Plant_w_ID('P1')</p>
  
  <p>iii) define a 'getter' method in the Plant_w_ID class to retrieve the value of ID attribute accordingly</p>
  
  <p>Finally, what is the purpose of have a getter method to do so?
  Here is the script that is written by me. Thank you.</p>
  
  <pre><code>import random
  genome_length =50
  bases = ['A', 'C', 'T', 'G']
  
  class Plant:
     def __init__(self):
     self.genome = []
     self.genome = [random.choice(bases) for _ in range(genome_length)]
  
  class Plant_w_ID(Plant):
     def __init__(self, plant_id):
         super().__init__()
         self.plant_id = plant_id
  
     def add_plant_id(self, plant_id):
         for i in range(len(plant_list)):
         plant_id='P'+str(i)
         plant_list.append(plant_id)
  
  def main():
      plant_list = []
      for x in range (5):   
          plant =Plant_w_ID()
          plant_list.append(plant)
  </code></pre>