Answers for "python import copy"

1

python copy variable

>>> import copy
>>> a = 0
>>> b = 2
>>> a = copy.copy(b)
>>> b += 1
>>> a
2
>>> b
3
Posted by: Guest on June-02-2020
0

python copy

org_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
new_list = org_list.copy()

# For lists in lists you need deepcopy()

import copy

org_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
new_list = copy.deepcopy(org_list)
Posted by: Guest on February-20-2022

Python Answers by Framework

Browse Popular Code Answers by Language