diff --git a/0x0A-python-inheritance/101-add_attribute.py b/0x0A-python-inheritance/101-add_attribute.py new file mode 100644 index 0000000..6ee534e --- /dev/null +++ b/0x0A-python-inheritance/101-add_attribute.py @@ -0,0 +1,13 @@ +#!/usr/bin/python3 +""" +adds an object +""" + + +def add_attribute(obj, name, value): + """ + adds a new attribute to object + """ + if not hasattr(obj, "__dict__"): + raise TypeError("can't add new attribute") + setattr(obj, name, value)