0

lists, I got the answer by guessing...

The question: nums=[1,2,3,4,5] nums[3]=nums[1] print(nums[3]) can someone explain how this answer is figured out?

29th Jul 2016, 8:34 PM
Anthony D'Amico
Anthony D'Amico - avatar
4 Answers
+ 1
in python you should know that whenever there is an equals sign between two already assigned variables the always the value of the right sided variable will come in the left sided variable... you should also note that this is not applicable to the right sided number that the value of left will come to it... nums [3] = nums[1] it means that the value of nums[ 1] is now in nums[ 3] ...so that is the reason behind it... this feature is available in java also .... I hope you understand. ... it.... have a nice day.....
31st Jul 2016, 12:13 PM
Aakash Sharma
Aakash Sharma - avatar
0
yes thank u, that makes sense now
29th Jul 2016, 8:51 PM
Anthony D'Amico
Anthony D'Amico - avatar