Skip to content

Instantly share code, notes, and snippets.

@mjhea0
Created February 28, 2015 18:28
Show Gist options
  • Save mjhea0/d746254e524f6e692773 to your computer and use it in GitHub Desktop.
Save mjhea0/d746254e524f6e692773 to your computer and use it in GitHub Desktop.
d1 = {'Name': 'John', 'Age': '25', 'DOB': None}
d2 = {'Name': 'ABC', 'Age': None, 'DOB': '10/20/1983'}
d2.update({key: value for key, value in d1.items() if value})
print(d2) # => {'DOB': '10/20/1983', 'Age': '25', 'Name': 'John'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment