HOW does this work? In indexing a list, if i give give two index parameters like in the code given below:
i am getting an output if i give the second parameter as  but an error for anything else, why? Code: num = [5, 4, 3, , 1] print(num) Output: 2
Data types for Index0 = integer Index1 = integer Index2 = integer Index3 = list (list of list) Imdex4 = integer You can only use  for list so an error would occur if you try it on any other datatypes in the list above
Rayyan At index 3 there is a list so it can also be indexed . Whereas other are integers you cannot index them..
Index 3 accesses the 4th item of the list: num gives  which is itself another list This other list can also be idexed but it has only one element, so the only existing index possible is 0. that is why: num gives 2 any other index thant 0 does not exists in the inner list, so it raises an error.
go to the ict teacher