QuestionQ61

VerifiedData Collections – Tuples, Dictionaries, Lists, and Strings

What is the resulting output of the following code?

Question Image

Explanation

List slicing creates a new list, so modifying y does not affect w. Assignment without slicing binds z to the same list as w; therefore, setting z[1] to 20 also changes w to [7, 20, 23, 42].

Community Discussion

No comments yet. Be the first to start the discussion!