← Quiz: Distributed Transactions and Sagas: all 10 questions
Quiz: Distributed Transactions and Sagas · Question 4 of 10
What does this print? (code)
What does this print?
done = ["charge", "accept"]
undo = {"charge": "refund", "accept": "cancel"}
print([undo[s] for s in reversed(done)])
- A.['refund', 'cancel']
- B.['cancel', 'refund']
- C.['charge', 'accept']
- D.['accept', 'charge']
Answer & explanation
Correct answer: ['cancel', 'refund']
Compensations run in reverse order: undo the latest completed step first.
Can you get the rest right without peeking?
Take the timed Quiz: Distributed Transactions and Sagas quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →