Code Room
Code reviewHard
Question
Review this Python (psycopg2) function that posts a double-entry journal.
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 post_journal(conn, debit_acct, credit_acct, amount): cur = conn.cursor() cur.execute("UPDATE accounts SET balance = balance - %s WHERE id = %s", (amount, debit_acct)) conn.commit() cur.execute("UPDATE accounts SET balance = balance + %s WHERE id = %s", (amount, credit_acct)) conn.commit()Run or narrate your approach, then ask the coach.