Preferred method for "Assignment by value"
robin at nibor.org
Tue Apr 15 21:25:43 CEST 2008
hall.jeff at gmail.com schrieb:
> by changing temp = v[:] the code worked perfectly (although changing
> temp.insert(0,k) to temp = [k] + temp also worked fine... I didn't
> like that as I knew it was a workaround)
So the for body now looks like this?:
temp = v[:]
It can still be clarified and simplified to this (may also be faster):
temp = [k] + v
Which one do you like better :)?
More information about the Python-list