+ 8
list1 = range(5) is [0,1,2,3,4] and list2 = range(10) is [0,1,2,3,4,5,6,7,8,9] according to the provided example. So, why does list1 index[4] not result in the answer 3?
8 Antworten
+ 9
Indexes start at 0. list1[4] is thus the 5th element of list1, ie 4. Same deal for strings.
+ 3
i have learned that counting lists and strings works differently. i now understand why the answer is 4.
+ 1
all indexes start with '0' like:
[0,1,2,3,4]
|0,1,2,3,4|
0
Thanks you all for the replies to johnathen, They solved also my doubt.
0
thank you for your help. by the way, Python is awesome!
0
Range elements count start from 1 and Index count start from 0.
0
coz are like array in Java de start counting with 0 not 1
0
all indexes start with '0' like:
[0,1,2,3,4]
|0,1,2,3,4|