+ 1
What do mean by indexing in python? And what does backward and forward indexing signify??
2 Respostas
+ 1
Indexing simply refers to giving your elements in any sequence(list, tuple, string etc.) some address so that we can retrieve them. Eg
List1 = [1,3,4,8,2]
Print(list1[1])
#since we are putting the parameter in square bracket which means the parameter is our index.
O/p - 3
Bcoz the indexing in list starts from 0.
I.e. index and elements
0 - 1
1 - 3
2 - 4
3 - 8
4 - 2
in the above program python looks for element in index number 1.
+ 1
list_2= [5,2,1,8]
forward indexing is in simple terms using +ve numbers for indexing and backward indexing is using -ve numbers.
element ~ forward index ~ backward index
5 ~ 0 ~ -1
2 ~ 1 ~ -2
1 ~ 2 ~ -3
8 ~ 3 ~ -4
eg: print(list_2[-3])
o/p- 1
#plz up vote and tick is you like explanation it takes quite some time to write.