Q.14 Observe the given list and find
the answer of questions that follows.
list1=[45, 77, 'next','try',33]
a.list[-2] b.list[2]
Answers
Answered by
6
Given list:
list1 = [45, 77, 'next', 'try', 33]
Correct questions:
- a. list1[-2]
- b. list1[2]
a. list1[-2]
Output: 'try'
b. list1[2]
Output: 'next'
Explanation:
a. When negative indexing is given, it means that the list is read in the reverse order [right to left]. The second last item was 'try', hence the output was 'try'.
b. When positive indexing is given, it means that the list is read from left to right. And indexing starts at 0. So the 2nd element accordingly was 'next', hence the output was 'next'.
Similar questions
Chemistry,
1 month ago
Accountancy,
1 month ago
Physics,
2 months ago
CBSE BOARD X,
8 months ago
Physics,
8 months ago
Physics,
8 months ago