List Accessing


#1



What am i supposed to do  in 1.1 list accessing? 
Some one plz help me... ;-)


#2

Please post your well formatted code or the exercise instructions.

Thank you! :smile:


#3

I t starts off like this:

n = [1, 3, 5]

print n[2]

The instructions are to print out the second element. How do I do this.


#4

Yea @byteace83915 im not sure if this applies to python but the list order is 0, then 1 then two.. It always starts with index 0... So correct solution would be:

 n = [1, 3, 5]

print n[1]

Understand or need clarification?


#5

I do need clarification.


#6

oh now I get it nevermind.


#7

Index(In Most Languages)

Ok so, basically when you do an array lets say:

n = [1,2,3,4,5,6]

Well you might think element 1 in that array is index 1. But An Array ALWAYS, starts in index 0, in all the langauges i learned atleast.. So if you want to acess the element 1.. you would do

print n[0]

Example

So now lets say now you want element with the value 4... Ok so lets start to count from 0 and reach to 4.

Diagram

Elements         [   1,    2,    3,    4,     5,     6    ]

INDEX                0     1     2     3      4      5

So as you can see in above diagram element with value 4 is in index position 3. So then you do:

print n[3]

Still need clarification?