How do I access the 2nd item in a list?

Question

How do I access the 2nd item in a list?

Answer

Recall that lists start counting from 0, not 1! So if we want to access an item, we start as 0 for the index of the first item, and count our way up to the item we want.
In this case, we’re given a list n = [1, 3, 5], so the second element is 3, and has an index of 1.

1 Like

if n=[1,3,5]

then Why is it wrong to type the code as print n[1:2] to print the second element in the list .

it is giving output as [3] instead of output 3

If you just want a single element from the list, why using list slicing?

Also, remember, lists are zero indexed based, so the first element is positioned at index 0