Mikola has the right answer but a little more explanation. It will run the first time, but because append returns None
, after the first iteration of the for loop, your assignment will cause list1
to equal None
and therefore the error is thrown on the second iteration.