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"]))
Larz60+ write Apr-22-2022, 05:16 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.