0

What does the return value (None) for the extend function indicate.

common_birds = ["chicken", "blue jay", "crow", "pigeon"]
birds_seen = ["sparrow", "green finch", "gold finch"]

print (common_birds.extend(birds_seen))
# returns None

common_birds.extend(birds_seen)
print (common_birds)
# returns the extended list
chribonn
  • 445
  • 5
  • 20

2 Answers2

6

It means that the method doesn't return something, but works "in place" by extending the list. You're not returning a new list, but changing the old one.

LukasNeugebauer
  • 1,331
  • 7
  • 10
0

It means that the method does not have a result that you could work with. Instead it has a side effect.

Hopefully the only side effect is the one you'd expect, i.e. that the list is extended.

In your life you'll find void methods that have several side effects, some of which are unwanted.

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222