+ 1

Python - Why is result "None"?

A = [1,2] B = [3,4] C = A.extend(B) print(C)

5th Oct 2019, 10:34 AM
Paolo De Nictolis
Paolo De Nictolis - avatar
4 odpowiedzi
+ 3
"Extend" method does a work but returns nothing. So C becomes None. An example: def func (x,y): x =x+y This function returns nothing to it's caller but does a work and changes it's arguments.
5th Oct 2019, 10:48 AM
Qasem
+ 2
Here's a very good explanation about your problem https://stackoverflow.com/a/29998477
5th Oct 2019, 10:41 AM
alvaro.pkg.tar.zst
alvaro.pkg.tar.zst - avatar
+ 1
You right! If after print(C) I write print(A), it outputs [1,2,3,4]
5th Oct 2019, 10:51 AM
Paolo De Nictolis
Paolo De Nictolis - avatar