Question: what is wrong with my code. class Chicken: total _ eggs = 0 def _ _ init _ _ ( self , name, species )

what is wrong with my code. class Chicken:
total_eggs =0
def __init__(self, name, species):
self.name = name
self.species = species
self.eggs =0
def lay_egg(self):
self.eggs +=1
Chicken.total_eggs +=1
return self.total_eggs
c1= Chicken(name="Alice", species="Partridge Silkie")
c2= Chicken(name="Amelia", species="Speckled Sussex")
print(Chicken.total_eggs)
(c1.lay_egg())
print(Chicken.total_eggs)
(c2.lay_egg())
(c2.lay_egg())
print(Chicken.total_eggs)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!