multiple assignments with a comma in python -


i tried find explanation of this, gotcha part:

b = "1984" = b, c = "ab" print(a, b, c) 

returns:

('ab', 'a', 'b') 

i understand happens multiple equals:

a = b = 1 

but using comma, cannot understand behaviour, ideas in why works way?

the answer

a = b, c ="ab" 

acts like:

a = (b, c) = "ab" 

this why:

a = "ab" , b = "a" , c = "b" 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -