Send Query Parameters Properly

Easy ⏱ 8 min 85% acceptance ★★★★★ 4.9
Never hand-concatenate query strings — spaces and & break URLs. Write search_products(url, term, max_price) passing params={'q': term, 'max_price': max_price} to requests.get so encoding is automatic, returning the parsed JSON list.

Examples

Example 1
Input
search_products(url, 'desk lamp', 2000)
Output
parsed results for ?q=desk+lamp&max_price=2000
Explanation

requests URL-encodes the space for you.

Constraints

  • Use the params argument.
  • No manual ? or & building.

Topics

APIsparams

Companies

GoogleZomatoMakeMyTrip

Hints

Hint 1

params takes a plain dict.

Hint 2

The encoded URL is visible on response.url if curious.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.