I'm using extend
function to add new item in a list. And gives me None
in output.
p=["a",1,"b",2,"c",3]
a=p.extend(["d",4])
print(a)
Output None
Why It is giving none instead of ['a', 1, 'b', 2, 'c', 3, 'd', 4]
I'm using extend
function to add new item in a list. And gives me None
in output.
p=["a",1,"b",2,"c",3]
a=p.extend(["d",4])
print(a)
Output None
Why It is giving none instead of ['a', 1, 'b', 2, 'c', 3, 'd', 4]
Because using extend
function, you just extend it but not make any new list. So nothing is assigned it variable a
. You should do following:
p=["a",1,"b",3,"c",4]
p.extend(["qeq",14])
print(p)
This method does not return any value but add the content to existing list. Check this for more.