Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

iterate through dict with condition

>>> categories=   [{ 'Id': 1350, 'hasCategory': True},
               { 'Id': 113563, 'hasCategory': True},
               { 'Id': 328422, 'hasCategory': False}]
>>> [i['Id'] for i in categories if i['hasCategory'] == True]
[1350, 113563]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #iterate #dict #condition
ADD COMMENT
Topic
Name
4+6 =