0
Python - Why is the output None when the extend() method is placed inside print()?
x = [1,2,3] x.extend([4,5,6]) print(x) # outputs [1, 2, 3, 4, 5, 6] x = [1,2,3] print(x.extend([4,5,6])) # outputs None --> Why does this NOT output [1, 2, 3, 4, 5, 6]?
2 Respostas
+ 5
extend is a method that doesn't return anything. It operates "in place" so it changes the list.
+ 3
The function <list>.extend() doesn't return a value.
The function just extends the list.