Code Room
Code reviewHard
Question
Review this Python counter persisted to a shared file.
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
import json, os COUNTER_FILE = "/var/lib/app/counter.json" def increment_counter(): if os.path.exists(COUNTER_FILE): with open(COUNTER_FILE) as f: state = json.load(f) else: state = {"count": 0} state["count"] += 1 with open(COUNTER_FILE, "w") as f: json.dump(state, f) return state["count"]Run or narrate your approach, then ask the coach.