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.
Source:stackexchange.com