0
I don't understand this one.
nums=[1,2,3,4,5]nums [3]=nums [1]print (nums [3])how the answer could be 2?
9 Answers
+ 4
Because with "nums [3]=nums [1]" you make the third number ( which, as we know, it's actually the forth since you have to start counting from 0, not 1) , in this case 4, turn into the first number (actually the second) , which is 2.
+ 2
after executing nums[3] =nums[1], the list is changed to [1,2,3,2,5]. since index starts from 0.
+ 2
list 3 index means 4 th position in list and 1 index means 2 position. now compare ...
+ 1
List index 3 has value of 4 and is replaced by value of index 1 which is 2. Now position 3 has value of 2, copied from index 1.
Hope you understood it.
+ 1
Cuz nums[0]=1,nums[1]=2,nums[2]=3,nums[3]=4,nums[4]=5.
0
ŠŠ°Š»ŠŗŠ¾ ŃŃŠ¾ ŠŗŠ¾Š¼Š¼ŠµŠ½ŃŠ°ŃŠøŠø Š½ŠµŃ Š½Š° ŃŃŃŃŠŗŠ¾Š¼
0
because when u do this
nums [3]=nums [1] .... the num [3] value will over write and num [3] shows the value of num[1]
0
You replaced the 4 with a 2, but the 2 itself remained unchanged.
- 2
Test it out.