1 List accessing need halp


#1

Ok so this is very weird its asking me to

Please add the code to print out the second element in the list.

and gave me this code saying,,,

n = [1, 3, 5]
with hints saying...Remember that elements in a list start from index 0 and they are accessed in the form

x[n]
where x is the name of the list and n is the index in that list that you're trying to access.

plz halp


#2

Examine the indexes of the list, and their values. Starting at index 0, we have n[0] == 1, the first element. The second element then will be...?


#3

so the second element will be n[2] == 3 and n[4] == 5 ?


#4

There are only three elements in all,

n[0] == 1
n[1] == 3
n[2] == 5

Index numbers are sequential, starting at 0.


#5

and so the code wants us or me to type that into python as a code right. So how will I be able to do that?


#6

The second element is n[1] so we would just print it:

print n[1]    # prints 3

#7

OOOOOOOOO ok I get it now thanks
:smile: