Indexing a list of elements

a = [1,2,3,4.5,“Nouh”, [1,2,3], True]
a[-1]

I used negative index to retrieve the last element of the list. But instead of True, the output will be [1,2,3]. Why is the output is not True.

As written that shouldn’t happen, which makes me think there was a bug in the original code but not in your post. Can you copy-paste the code and output where you saw this, or even a screenshot? Normally a screenshot is not helpful but it looks like something is being lost in the posting process.

1 Like


This the code i have run to index.

Did anything interesting happen in code cells [11] to [16]?

Note that the output isn’t even the same value as in the original: it’s [1, 2, 3.2] instead of [1, 2, 3.5]

2 Likes

I think now i sorted out the problem. my code output is True which is the last index of the list.