Delete on a copy of a copy 2D dictionnary | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Delete on a copy of a copy 2D dictionnary

When I delete an element from a copy of 2D dictionnary, i realise that this delete was done also on.the original 2D dictionnary, but with dictionnary of 1D dictionnary i don t have this issue. Look at the code bellow https://code.sololearn.com/cx7pHL45W70g/?ref=app

22nd Jan 2020, 8:21 AM
Zakaria BEN
Zakaria BEN - avatar
2 Answers
+ 4
You can use copy.deepcopy method to fix this problem with multidimensional iterables: import copy net1copy=copy.deepcopy(net1) net2copy=copy.deepcopy(net2)
22nd Jan 2020, 9:11 AM
Seb TheS
Seb TheS - avatar
+ 1
Thanks Seb for your help, i had imported copy and applicate the method copy.deepcopy, and now it is functionning
22nd Jan 2020, 9:18 AM
Zakaria BEN
Zakaria BEN - avatar