Question 10
Back to Exercise
The program below stops with an error. Which statement correctly describes the problem?
class Settings:
theme = "dark"
for option in ["theme", "font_size"]:
print(option, getattr(Settings, option))
- A AttributeError: Settings has no font_size; pass a default, e.g. getattr(Settings, option, None) Correct
- B It prints font_size None
- C KeyError
- D NameError
Correct Answer: Option A
"theme dark" prints first; the second lookup fails without a default.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!