Complete the code to get the value of the 'category' query parameter from the URL.
category = request.args.get('[1]')
The query parameter name to filter by category is 'category'. Using request.args.get('category') retrieves its value.
Complete the code to check if the 'price' query parameter exists in the request.
if '[1]' in request.args:
To check if a query parameter exists, use its exact name in the request arguments. Here, 'price' is the parameter to check.
Fix the error in the code to convert the 'limit' query parameter to an integer safely.
limit = int(request.args.get('[1]', 10))
The 'limit' parameter controls how many items to return. Using request.args.get('limit', 10) gets it or defaults to 10, then converts to int.
Fill both blanks to filter items by 'category' and 'max_price' query parameters.
category = request.args.get('[1]') max_price = request.args.get('[2]')
To filter by category and maximum price, use the query parameters named 'category' and 'max_price'.
Fill all three blanks to create a dictionary comprehension filtering items where 'category' matches and 'price' is less than max_price.
filtered_items = {item: data[item] for item in data if data[item]['[1]'] == [2] and data[item]['[3]'] < max_price}This comprehension filters items where the 'category' equals 'electronics' and the 'price' is less than max_price.