Message224590
This is not a bug. The assignment "a = nums" doesn't create a copy of "nums", it just assigns the name "a" to the same object that "nums" refers to. Since lists are mutable, changes made to "a" are visible through the name "nums". By the time you do "a[2] = nums[0]", "nums[0]" has been reassigned.
Have a look at this article: http://nedbatchelder.com/text/names.html
Also, you may want to look at collections.deque and its rotate method. |
|
Date |
User |
Action |
Args |
2014-08-02 21:34:29 | zach.ware | set | recipients:
+ zach.ware, Sai.Krishna.G |
2014-08-02 21:34:29 | zach.ware | set | messageid: <1407015269.87.0.996462401324.issue22124@psf.upfronthosting.co.za> |
2014-08-02 21:34:29 | zach.ware | link | issue22124 messages |
2014-08-02 21:34:29 | zach.ware | create | |
|