im trying to exclude some key when passing a dict to a variable. for example.
dict1 = {
'id': 1,
'name' : 'John Woe',
'flag' : True,
'position' : 'Developer'
}
Now i would like to exclude the key flag
or any specified keys when passing it to dict2
variable. Normally i can simple hardcodedly assign it but i want a dynamic approach.
Such as this:
dict2 = dict1.exclude(['flag', 'position'])