QuestionQ199

VerifiedData Collections – Tuples, Dictionaries, Lists, and Strings

What is the expected output from the following code?

Question Image

Explanation

The slice data[-2:-1] produces the one-item tuple (3,) because the ending index is excluded. Accessing index -1 of that tuple returns its final—and only—element, 3.

Community Discussion

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