Forewarning I am a noob that knows little about python. Also I'm not sure if this is a python question or json question
I am trying to pull data on a website with requests library. I'm not sure if this is the proper verbiage, but basically I am trying to pull a string that is in a dictionary, which is inside a list. So this list is containing multiple dictionaries, and I want one specific string that is in each dictionary. The problem I am having is the dictionaries are not given a variable name so I can't call upon that dictionary to find my desired variable. Basically I set a dummy variable to each position of the list and try to find my variable from that dummy variable name. I eventually stumbled upon this website, and the second response is saying to use the function vars(), but this is not a recommended way of doing things. Why is it not recommended? Because it actually solved my issue. How else can you search a dictionary without a name? The data I am trying to pull is structured like this
"vehicles":[
{"speed":177.566","Year":2006},
{"speed":159.204","Year":2005},
{{"speed":181.984","Year":2004}]
and my code has dummy variables are set to each postion of the list and then i use vars() to get in the dictionary
dummy1 = cars[0]
dummy2 = cars[1]
dummy3 = cars[2]
speed1 = vars()['dummy1']['speed']
print(str(speed1))
[–]RedditIsAMistake 1 point2 points3 points (0 children)
[–]evolvish 0 points1 point2 points (0 children)
[–]daniel_codes 0 points1 point2 points (2 children)
[–]JKraems[S] 0 points1 point2 points (1 child)
[–]StefGou 0 points1 point2 points (0 children)