Computer Science, asked by rambairawat98270, 2 months ago

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 Equestriadash
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