Skip to main content

Practice · 3 of 3

Predict the MRO chain

CHALLENGE
Difficulty: advanced+25 XP

Without running it first (then run it!), implement the classes so that chain() returns the exact call order of who() across the hierarchy when called on a D instance. Classes: A defines who returning 'A' and logs to a shared list. B(A) overrides who to log 'B' then super().who(). C(A) overrides who to log 'C' then super().who(). D(B, C) overrides who to log 'D' then super().who(). chain() must reset the log, call D().who(), and return the list — expected ['D', 'B', 'C', 'A'] following the MRO D→B→C→A.

Back to lesson: Practice: Attribute Lookup Practice