Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Search in a list of dicts

lstdict = [
        { "name": "Klaus", "age": 32 },
        { "name": "Elijah", "age": 33 },
        { "name": "Kol", "age": 28 },
        { "name": "Stefan", "age": 8 }
       ]

print([x for x in lstdict if x['name'] == 'Klaus'][0])
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #Search #list #dicts
ADD COMMENT
Topic
Name
4+1 =