range | Sololearn: Learn to code for FREE!

+5

range

nums=list(range(5)) print(nums[4]) answer should be 3. but sololearn is giving answer 4 as correct. nums=[0,1,2,3,4] nums[4] should be 3

9/4/2019 7:58:09 AM

Mugdha Gandhi

2 Answers

New Answer

+11

Mugdha Gandhi Indexing starts from 0 so nums[0] = 0 (the first element) hence nums[4] = 5th element(if you start counting from 1) which is 4 (nums[4] is 4)

-1

Same doubt 🙄🙄