0

i don't understand this nums=[7,7,7,7,7] nums[2]=5 print(nums) ans: [7,7,5,7,7] how??

8th Sep 2016, 4:48 PM
gala
gala - avatar
4 Answers
+ 2
indexing starts with 0
8th Sep 2016, 4:54 PM
Amarie
+ 2
I think because the index of the array starts with 0 so changing nums[2] to 5 will change the 3rd number in the array. I'm still new to coding though.
8th Sep 2016, 4:54 PM
Lub Pig
Lub Pig - avatar
+ 1
aaam I understand now.. I need replace it
8th Sep 2016, 4:55 PM
gala
gala - avatar
+ 1
first,you assigned nums list and in the second line you told the IDE to add another number '5' in the 3rd sequence of the list. This is a way to add a data to a list.
9th Sep 2016, 10:13 AM
Jarif
Jarif - avatar