QuestionQ142

VerifiedData Collections – Tuples, Dictionaries, Lists, and Strings

Consider this code.

Question Image

What does the second assignment do?

Explanation

Tuple assignment swaps the values at indices 0 and 2. With a three-item list whose middle element remains unchanged, swapping the first and last elements reverses the list.

Community Discussion

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