You need to create a dict3 dictionary that will contain all pairs (including None ) of dict2 , but not those of None that come out of dict1 :

 dict1 = {'email' : 'abcd@gmail.com', 'name' : 'Michael', 'surname' : 'Stans'} dict2 = {'login' : dict1.get('email'), 'name' : dict1.get('name'), 'surname' : dict1.get('surname'), 'number' : dict1.get('number'), # (None)- не нужен 'age': dict1.get('age'), # (None)- не нужен 'salary' : None, # (None)- нужен 'weight': None} # (None)- нужен dict3 = {?} 
  • one
    You need a list of all the things from dict1 that you insert into dict2 ( ['email', 'name', 'surname', 'number', 'age'] ) otherwise it is impossible to distinguish different types of None - SamYonnou

1 answer 1

If only so

 dict1 = {'email' : 'abcd@gmail.com', 'name' : 'Michael', 'surname' : 'Stans'} dict2 = {'login' : dict1.get('email'), 'name' : dict1.get('name'), 'surname' : dict1.get('surname'), 'number' : dict1.get('number'), # (None)- не нужен 'age': dict1.get('age'), # (None)- не нужен 'salary' : None, # (None)- нужен 'weight': None} # (None)- нужен values_got_from_dict1 = ['login', 'name', 'surname', 'number', 'age'] dict3 = { k:v for k,v in dict2.items() if v or (not v and k not in values_got_from_dict1)} print(dict3)