Python - Custom Exceptions
What will be the output of this code?
class Person:
pass
p = Person()
setattr(p, 'name', 'Alice')
print(p.name)class Person:
pass
p = Person()
setattr(p, 'name', 'Alice')
print(p.name)setattr(object, attribute_name, value) adds or updates an attribute on the object.name is set to "Alice" on instance p. Printing p.name outputs "Alice".15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions