0
Regarding List|| range
What is the result of this code? nums = list(range(5)) print(nums[4]) The answer is 4 in Sololearn. My perspective is the answer is 3 because list contains values as [0,1,2,3,4], then why the answer is 4
1 Answer
0
it's correct. it asks for the element of index 4 from the list. the index 4 is the 5th element from the list, so:
num [0] = 0
num [1] = 1
num [2] = 2
num [3] = 3
num [4] = 4