Avatar ·

Assignment of values in Python. The difference in methods

📁 Advanced Python Topics, example

Why are different results obtained in 2 cases?

Example 1:

  a =  1  b =  2  c =  3  d =  4  e =  5  f =  6  a, b, c, d, e, f = e, f, a, b, c, d  print  a, b, c, d, e, f  

Result 1:

5 6 1 2 5 6

Example 2:

  a =  1  b =  2  c =  3  d =  4  e =  5  f =  6  a = e b = f c = a d = b e = c f = d  print  a, b, c, d, e, f  

Result 2:

5 6 5 6 5 6