Advertisement
here2share

# dict_remove_keys_with_empty_values.py

Sep 7th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.17 KB | None | 0 0
  1. # dict_remove_keys_with_empty_values.py
  2.  
  3. d = {1:'',2:None,3:'',4:'a',5:'b',6:'',7:'c',8:'',9:0,10:''}
  4. data = {k: v for k, v in d.items() if v!='' and v!=None}
  5. print data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement