Why does this list swap fail?

Rob Gaddi rgaddi at highlandtechnology.invalid
Mon Nov 14 14:07:36 EST 2016


380162267qq at gmail.com wrote:

> L=[2,1]
> L[0],L[L[0]-1]=L[L[0]-1],L[0]
>
> The L doesn't change. Can someone provide me the detail procedure of this expression?

Better question: Why does that list swap exist?  If you're just trying
to put the language through its paces that's one thing, but I certainly
hope that's not actually going to be production code.  Even if it were
right it's unreadable.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.



More information about the Python-list mailing list