fork download
  1. print("Regular multiplication.")
  2. x = [[1,2], [3,4]]
  3. y = x[1]
  4. y = y * 2
  5. print(x)
  6. print(y)
  7.  
  8. print("In-place multiplication")
  9. a = [[1,2],[3,4]]
  10. b = a[1]
  11. b *= 2
  12. print(a)
  13. print(b)
Success #stdin #stdout 0.03s 9328KB
stdin
Standard input is empty
stdout
Regular multiplication.
[[1, 2], [3, 4]]
[3, 4, 3, 4]
In-place multiplication
[[1, 2], [3, 4, 3, 4]]
[3, 4, 3, 4]