Copy Functions
copy.copy()
Make a shallow copy when supported. A new outer collection usually shares nested objects; immutable objects may be returned unchanged. Custom __copy__ hooks can control copying.
Formal Syntax & Structure
python syntaxpython
copy.copy(obj)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| obj | object | Object to inspect or copy. |
Return Value
object
The object result described above.
Working Example
Example Snippetpython
import copyoriginal=[[1], [2]]clone=copy.copy(original)clone[0].append(9)print(original, clone is original)