-2

I am a beginner to programming and was working in a for loop and realised the error I was getting is because of the reason in the title. Why Does the happen anyway? Is this a general property of mutable ojects?.

T

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
deftextra
  • 123
  • 1
  • 7
  • `help(list.append)` shows `append(...) L.append(object) -> None -- append object to end`. Functions that mutate objects don't normally also return the object. But in the end, its just doing what its documented to do. – tdelaney Apr 20 '17 at 20:51

1 Answers1

0

append modifies the list in place. There is no need to do L=L.append(x); Simply running L.append(x) should suffice. The reason L is being set to none in your code is because there is no return value for append

SoZettaSho
  • 950
  • 11
  • 20