[Answer]-Filter a list of dicts based on id

1👍

Here is how it should be

categories = [{u'id': 19, u'name': u'SYWSUB'},
 {u'id': 20, u'name': u'SYWSU'},
 {u'id': 40, u'name': u'Others'},
 {u'id': 41, u'name': u'rohit'},
 {u'id': 42, u'name': u'ssc'}]

current_course_category = 42
print [cat for cat in categories if cat['id'] != current_course_category]

I hope this helps.

0👍

[ {key: value} for key, value in your_dict.items() if key != 42 ]

This should do it

Leave a comment