Python check if multiple values match search criteria in JSON file

I have the following code:

import requests
from bs4 import BeautifulSoup
import urllib, json

url = ""
response = urllib.request.urlopen(url)
json_data_xbox = json.loads(

name_var = "Salah"
rating_var = "96"

if name in json_data_xbox["player"].__str__(): # here I don't know what to write to check if name + rating are matching

    print("not matching")

This is the corresponding JSON file:

{"player": [{"name": "Salah", "rating": "96", "rarity": "TOTS", "prices": 5380000}, {"name": "Salah", "rating": "93", "rarity": "FOF PTG", "prices": 956000}] 

As you see, I have two entries with the same name but different rating and prices. I would like to check if two variables can be found within one object in my json dictionary to match the right one. So in this example I want to check if name_varand rating_var are matching to then get the correct "prices" value.

What would I need to write to get that check done?


You would probably want to loop over each dictionary in the response and check that the key values are equal to your variables. Could do something like this:

    json_data_xbox = json.loads(
    '{"player": [{"name": "Salah", "rating": "96", "rarity": "TOTS", "prices": 5380000}, {"name": "Salah", "rating": "93", "rarity": "FOF PTG", "prices": 956000}]}')

name = "Salah"
rating_var = "96"

price = ""

for i in json_data_xbox["player"]:
    if i["name"] == name and i["rating"] == rating_var:
        price = i["prices"]