listOneandlistTwo=listOne.extend(listTwo)
extend()
extends the given list but returns None
*, so you have extended listOne
with the contents of listTwo
and assigned None
to listOneandListTwo
.
What you want (assuming you want to leave listOne
and listTwo
as they are) is this:
listOneandlistTwo = listOne + listTwo
* This behavior is by design. If extend()
returned the extended list, would it return a copy that's extended? Or would it return the original list extended? It's another detail to remember, so by returning None
you are meant to think, "oh, since it's returning None
it must be extending the list in place, otherwise it'd be useless."
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…