Skip to content

codes #202

@adityassuryawanshi25-bot

Description

import copy

original_list = [1, 2, [3, 4]]

Shallow copy example

shallow_copied_list = copy.copy(original_list)
shallow_copied_list[2][0] = 99
print(f"Shallow copy result: {original_list}") # Output: [1, 2, [99, 4]]

Deep copy example

deep_copied_list = copy.deepcopy(original_list)
deep_copied_list[2][0] = 55 # Change to a different value for clarity
print(f"Deep copy result: {original_list}") # Output: [1, 2, [3, 4]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions