Code RoomBalance updates lose deposits
MediumPrep Room Coding #1649

Balance updates lose deposits

Code reviewConcurrencyMid–Senior~22 min

Review this Python balance-update used by a thread pool.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 22 min
Mark a line and say what kind of problem it is.0 findings
1class Wallet:
2 def __init__(self):
3 self.balance = 0
4 
5 def deposit(self, amt):
6 self.balance += amt
7 
8 def withdraw(self, amt):
9 if self.balance >= amt:
10 self.balance -= amt
11 return True
12 return False
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.