Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python filter a dictionary

d = dict(a=1, b=2, c=3, d=4, e=5)
print(d)
d1 = {x: d[x] for x in d.keys() if x not in ['a', 'b']}
print(d1)
 
PREVIOUS NEXT
Tagged: #python #filter #dictionary
ADD COMMENT
Topic
Name
3+4 =