- 1

Im in lists...

Im doing the solo course thing and im in lists. Anyway it keeps making weird answers. Apparently if you make a list of 5 numbers, 1-5, and in the next line it says num: [3], then apparently the answer would be 2 since 5=0, 4=1, 3=2, 2=3, and 1=4?

14th Jul 2017, 4:12 PM
JoeIsCool
4 Respostas
+ 2
I'm not good understanding what you're trying to describe, but... if you define a list as: a = [1,2,3,4,5] ... then you've got: a[0] == 1 a[1] == 2 a[2] == 3 a[3] == 4 a[4] == 5 ... as indexes of list items start at zero, not at one ^^
14th Jul 2017, 4:49 PM
visph
visph - avatar
0
So if it counts from 1-6 instead of 5 in a list and it selects num: 4 for example, would 6 =0 from then on out and it counts down from 6 and up from 0?
14th Jul 2017, 4:14 PM
JoeIsCool
0
The indexes start from 0, no matter what are the elements. [5, 4, 3, 2, 1] 0, 1, 2, 3, 4 [6, 5, 4, 3, 2, 1] 0, 1, 2, 3, 4, 5
14th Jul 2017, 4:46 PM
Boris Batinkov
Boris Batinkov - avatar
0
Thanks doods
14th Jul 2017, 5:21 PM
JoeIsCool