Code Room
Code reviewMedium
Question
Review this Python checkout endpoint. The team says 'the React form already validates quantity and price before submit.'
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
@app.post('/cart/checkout')def checkout(): body = request.get_json() total = 0 for item in body['items']: # price and qty validated in the browser form total += item['price'] * item['quantity'] order = create_order(user_id(), items=body['items'], total=total) charge(user_id(), total) return jsonify({'order_id': order.id})Run or narrate your approach, then ask the coach.