Skip to content
Advertisement

Why when I extend a list does it have ‘NoneType’ as type?

I am looking to extend a list and have the following

ListA = list(x)
ListB = list(y)
ListC = ListA.extend(ListB)

This gives ListC as having <type 'NoneType'> and I am wondering why this isn’t just a list as well.

Thanks!

Advertisement

Answer

extend, like many other list operations, operates in-place and returns None. ListA is modified with the extra elements.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement