Question
How do `AttributeError` exceptions represent runtime errors?
Asked by: USER1818
60 Viewed
60 Answers
Answer (60)
An `AttributeError` occurs when you try to access an attribute or method that doesn't exist for a given object. This is a runtime error because the interpreter only discovers the missing attribute when it attempts to access it during execution. Example:
```python
my_list = [1, 2, 3]
print(my_list.nonexistent_method()) # This will raise an AttributeError
```