[Tutor] multiple assignment on one line

Shashwat Anand anand.shashwat at gmail.com
Sun Nov 22 09:30:02 CET 2009


Ok, this is silly but i want to know is multiple assignment is possible in
one line using "+=, -=, *= etc" operators on python 2.6.4

like a,b = 0,1 which is equal to
a = 0
b = 1
on seperate lines.
similarly a = b = 0 which is equal to
a = 0
b = 0
on seperate lines.

Can we pack these two statements in one line ?
a += k
b += k
Both a,b are incremented by same value 'k'
ofcourse a,b +=k will not work but is there any such option available?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091122/6a4f4daa/attachment-0001.htm>


More information about the Tutor mailing list