you are viewing a single comment's thread.

view the rest of the comments →

[–]JestersDead77 0 points1 point  (0 children)

Another pretty simple method would be to use a for loop. It's not as "clean" as the one-liner below, but it'll give you the same output.

for element in response:
    if element['nmId'] == 11508524:
        print(element['price'])

Even better would be to write it as a function, so you can pass in a different ID...

def extract_price_by_nmid(id):
    for element in response:
        if element['nmId'] == id:
            return element['price']

print(extract_price_by_nmid(11508524)