0

What is the difference between using,(+, +=, .append) in the functions? I know that when I write mylist= mylist + [6, 7] is the same as when I write mylist+=[6, 7] as it's a shortcut. However, when i used + operator in proc function it didn't access the actual list directly so the actual list hasn't been changed, but when i used += operator it could access the actual list directly and changed it and also .append could access the actual list directly

I want to know the reason for this, + operator couldn't access the actual list and += operator could, however "mylist +=" is like a shortcut for "mylist=mylist+"

sTm
  • 1
  • 1
  • 1
    Possible duplicate of [Python: a += b not the same as a = a + b](https://stackoverflow.com/questions/6951792/python-a-b-not-the-same-as-a-a-b) – Josh Lee Feb 21 '18 at 03:54
  • It can be different!! – sTm Feb 21 '18 at 04:01
  • Possible duplicate of [Why does += behave unexpectedly on lists?](https://stackoverflow.com/questions/2347265/why-does-behave-unexpectedly-on-lists) – Stephen Rauch Feb 21 '18 at 04:07

0 Answers0