[Solved] Is there a way to search an object in a python list?


You can use a list comprehension to filter the data you need. For example:

# Data:
l=[{"id":"1", "name": "name1"}, {"id":"2", "name": "nam2"}, {"id":"1", "name": "name3"}]
print(len([x for x in l if x['id']=='1'])) # Result: 2
#         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#         This is the key part: you filter the list according to a condition
#         (in this case: x['id']=='1').
#         If all you need is the number of entries for which the condition
#         holds, printing the length of the resulting list will be enough.

solved Is there a way to search an object in a python list?