Posted By

dorseye on 08/12/09


Tagged

list python copy


Versions (?)

Copy a list


 / Published in: Python
 

  1. >>> myl = [1,3,5,7]
  2. >>> newl = myl[:]
  3. >>> myl
  4. [1, 3, 5, 7]
  5. >>> newl
  6. [1, 3, 5, 7]
  7. >>> myl[1] = 5
  8. >>> myl
  9. [1, 5, 5, 7]
  10. >>> newl
  11. [1, 3, 5, 7]

Report this snippet  

You need to login to post a comment.