I have a list of lists within which I want to search for a specific number to retrieve that specific list:
I have a list with values such as: [[266, 5300, 2696, 50.88], [36, 5191, 2938, 53.16], [875, 5133, 2553, 51.29]]
and I want to get the list with the one that contains the number 875
and I want to retrieve the second (5133
) and third (2553
) number in that list. How do I search for the 875 within this list and return those two values? I cant index because the order changes every time but the id (875
) will always be the first number in the list within a list.
I tried indexing but the order changes every time, I d'ont know how to search within the list to find a specific list starting with a number
Heres a snippet of the code but I have no clue where to start in terms of searching through the list:
id = {"id1": 887, "id2": 126}
url = "example.com"
# Send GET request to the URL
response = requests.get(url)
# Check if the request was successful (status code 200)
if response.status_code == 200:
# Parse the JSON response
json_data = response.json()
# Pretty print the JSON data
wr_value = json_data['header']['wr']
vsRTop = json_data['top']
How would I parse through 'top' to get the values using id1 for example?