What exception will be raised when you try to access an object attribute that is undefined?

Questions & AnswersCategory: PythonWhat exception will be raised when you try to access an object attribute that is undefined?
Lokesh Kumar Staff asked 2 years ago

What exception will be raised when you try to access an object attribute that is undefined?
a. ReferenceError
b. AttributeError
c. SyntaxError
d. NotImplementedError
e. NameError

1 Answers
Lokesh Kumar Staff answered 2 years ago

b. AttributeError

 

Explanation:
AttributeError is raised when an attribute reference (see Attribute references) or assignment fails. (When an object does not support attribute references or attribute assignments at all, TypeError is raised.)