Advertisement
Guest User

Untitled

a guest
May 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. ```
  2. import copy # this is the module to use
  3. l1 = [[10,20,30], 1, 2, 3]
  4. l2 = copy.deepcopy(l1) # create a copy using the deepcopy function from copy
  5.  
  6. l1.append(4) # append to list l1
  7. l1[0].append(40) # modify the inner list of l1
  8.  
  9. print( l1 )
  10. print( l2 )
  11. ```
  12.  
  13. **Output**
  14. *[[10, 20, 30, 40], 1, 2, 3, 4]*
  15. *[[10, 20, 30], 1, 2, 3]*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement