1. Home
  2. Data Science
  3. Python
  4. For nums = [10, 20, 30, 40], what is nums[-1]?

Added 2 Nov 2026

For nums = [10, 20, 30, 40], what is nums[-1]?

  1. 10
  2. An IndexError
  3. 40 Correct answer
  4. 30

Correct answer

C. 40

16 views

MCQSEXAM

Explanation

Negative indexing counts from the end: −1 is the last item and −2 the second-last. It works on strings and tuples too.

Reference

Asked in: NTS, PPSC, Python Developer Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs