Code Room
Code reviewMediumcr-g345
Subject EncodingLevel Mid–Senior~16 minCommon in Security · Databases & SQL interviewsIndustries Software development

Question

Review this Python that builds a search URL from a user's raw query and fetches the upstream results.

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.

Talk through your review
Code to reviewpython
import requests BASE = 'https://api.example.com/search' def search_url(query, limit=20):    # query is raw user input, e.g. 'cats & dogs' or 'a=1&b=2'    return f'{BASE}?q={query}&limit={limit}' def search(query):    url = search_url(query)    resp = requests.get(url, timeout=5)    resp.raise_for_status()    return resp.json()['results']
Run or narrate your approach, then ask the coach.