Apr-21-2022, 11:59 PM
Having issue with this piece of code, its an api that has json text but its not readable.
in _get_mean_subclass
for prod, v in response_API.item():
Attribute error: 'list' object has no attribute 'item'
in _get_mean_subclass
for prod, v in response_API.item():
Attribute error: 'list' object has no attribute 'item'
response_API = requests.get( f"https://api.bestbuy.com/v1/products(manufacturer=canon)?format=json&apiKey={cred.api_key}" ).json() def _get_mean_subclass(response_API): r = defaultdict(list) for prod, v in response_API.items(): # looking for keyword subclass or whatever its called r[prod].append(v["subclassId"]) return {k: mean(v) for k, v in r.items()} print(_get_mean_subclass(response_API["products"]))