Dictionary copy : Dictionary Copy : Dictionary PYTHON examples


PYTHON examples » Dictionary » Dictionary Copy »

 

Dictionary copy


Dictionary copy

#The copy method returns a new dictionary with the same key-value pairs ("shallow 
#copy," since the values themselves are the same, not copies):

x = {'username': 'admin', 'machines': ['foo', 'bar', 'baz']}
y = x.copy()
y['username'] 'mlh'
y['machines'].remove('bar')
print y

print x



           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Dictionary
» Dictionary Copy