Skip to content

Side-effects of reassigning empty list [] on the existing array list #14

Answered by goungoun
goungoun asked this question in Liner
Discussion options

You must be logged in to vote

unchanged. Only the variable nums will point to the new empty list.
nums = [1, 2, 3]
list_a = nums
nums = [] # Now nums points to an empty list
print(list_a) # Outputs: [1, 2, 3]

Replies: 1 comment

Comment options

goungoun
Aug 4, 2024
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by goungoun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Liner
Labels
None yet
1 participant