when trying to do that it is returning None.
x = [1,2,3].extend([4,5,6])
but [1,2,3] + [4,5,6] this is working fine can anybody tell me why?
I mean extend() function takes the same format, so why is it returning none?
when trying to do that it is returning None.
x = [1,2,3].extend([4,5,6])
but [1,2,3] + [4,5,6] this is working fine can anybody tell me why?
I mean extend() function takes the same format, so why is it returning none?
help(list.extend) will give you something like below:
extend(...)
L.extend(iterable) -> None -- extend list by appending elements from the iterable
So, extend do merge two list, but return None, as it is an in-place operation. For example:
>>> a = [1,2,3]
>>> print(a.extend([4,5,6]))
None
>>> a
[1, 2, 3, 4, 5, 6]