delattr(object, attribute) Removes the attribute of the input object object (required ) , input object for which the attribute will be removed. attribute ( required ), attribute to be removed.
In above code we created an object tiger. By using delattr() we removed one attribute age. The last line ( commented ) will generate error as we already removed the attribute age before using it.
AttributeError: 'Animal' object has no attribute 'age'
Deleting attribute of particular object.
We will create two objects and check that the delattr() will only delete for the input object only. Here in last line we can print the age of the other object lion.