Question 12
Back to Exercise
Why does sum([Money(1), Money(2)]) need __radd__?
- A sum starts with 0, so it computes 0 + Money(1), which needs Money.__radd__ Correct
- B sum adds from right to left
- C __add__ is ignored by sum
- D It does not need it
Correct Answer: Option A
int.__add__(Money) returns NotImplemented, so Python falls back to Money.__radd__(0).
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!