So basically I have this:
data = [
{
"id" : "hello",
...
},
{
"id" : "world",
...
}
]
and I want to get the result:
"1"
if I enter something like:
get_index(id="world")
And the main thing is that I don't want to loop through the array since there is a lot of data in it. If I were to loop it would be easy and I would end up with some code like:
for obj in data:
if obj['id'] == 'hello':
print(obj['id'])
But is there a direct way of doing this without looping?