Mid-Level
October 4, 2026

Spot the bug: Data Science & ML

One snippet. Find the bug, or prove there isn't one.

python
1import pandas as pd
2
3def enrich_orders_with_customer_emails(conn, orders: pd.DataFrame) -> pd.DataFrame:
4    cursor = conn.cursor()
5    emails = []
6    for _, row in orders.iterrows():
7        cursor.execute("SELECT email FROM customers WHERE id = %s", (row["customer_id"],))
8        result = cursor.fetchone()
9        emails.append(result[0] if result else None)
10    orders["email"] = emails
11    cursor.close()
12    return orders
13

Click the lines that carry the problem.

Your verdict

One attempt per day. The answer shows up right after.

Keep your streak

Create an account to keep your streak and track your progress.

Create an account