Code Room
Code reviewHard
Question
Review this Python (psycopg2) money-transfer function.
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.
Learn the concepts
def transfer(conn, src, dst, amt): with conn: # transaction cur = conn.cursor() cur.execute( "UPDATE accounts SET balance = balance - %s WHERE id = %s", (amt, src)) cur.execute( "UPDATE accounts SET balance = balance + %s WHERE id = %s", (amt, dst))Run or narrate your approach, then ask the coach.