0

Why the result of this is None?

fd =[] fd1 = fd.extend(["John", "M", 18]) print(fd1)

29th Oct 2020, 3:24 AM
Joe Ma
Joe Ma - avatar
3 odpowiedzi
+ 8
`extend` method works directly on the calling object (`list` object fd) and doesn't return a new (modified) `list` object . In Python, when a function/method doesn't explicitly return anything, a None object is returned. The same goes for `append` method. (Edited)
29th Oct 2020, 3:30 AM
Ipang
+ 3
Yes, you got that right 👍
29th Oct 2020, 3:42 AM
Ipang
+ 2
Ipang i see, that means I dont need fd1, just print fd after use the function, right?
29th Oct 2020, 3:41 AM
Joe Ma
Joe Ma - avatar