Simple Python code using constructors. Constructors has to be declared in the __init__ function inside the class.
class Fruit: def __init__(self,name): print("I'm " + name) # This is a constructor fruit1 = Fruit("Apple") fruit2 = Fruit("Orange")
I'm Apple I'm Orange
Constructors has to be declared in the init function inside the class.