I was experimenting with another question on Stack. I was trying to extend the list aa
so that it contain all elements of complete
. However, I came across this error. The following print statement prints None
:
complete = [5,4,3,2,1]
aa = [1, 2]
aa = aa.extend(complete)
print aa # prints None
However, if I change the code a bit like so:
complete = [5,4,3,2,1]
aa = [1, 2]
aa.extend(complete)
print aa # prints [1, 2, 5, 4, 3, 2, 1]
it works just fine. Why is it printing None
in the above code?