I have a list of dictionaries which has product info including reviews of each product. This is called "products_dicts"
Each product has a field called "Reviews"
I want to extract the Reviews for the product with a "uniq_id" = "b6c0b6bea69c722939585baeac73c13d"
I have tried the following:
for item in products_dicts():
if "uniq_id" == "b6c0b6bea69c722939585baeac73c13d"
print(products_dicts.Reviews)
CodePudding user response:
Without knowing what your dictionaries look like this is best guess:
for item in products_dicts:
if item.get('uniq_id') == 'b6c0b6bea69c722939585baeac73c13d':
print(item.get('Reviews'))
CodePudding user response:
Try something like this:
for product in products_dicts:
if product["uniq_id"] == "b6c0b6bea69c722939585baeac73c13d":
print(product["reviews"])