I made 2 lists (1 all strings, 1 all integers) using Python 3, tried to print and extend the first list with the other in the same statement, but ultimately got the output of none. Why?
# two lists, each with different data types
list_one = ["cat", "dog", "fish", "eye", "hook"]
list_two = [1, 2, 3, 4, 5]
# method that works and gives the expected output
list_one.extend(list_two)
print(list_one)
# method that doesn't work, gives an output of 'None'
print(list_one.extend(list_two))
Why does the second method give an output of 'None' instead of joining the two lists together?
Also, as I'm (very) new to programming, is it messy to put so many functions in a single statement?
list.extend()
returnsNone
. Use concatenation if you need a new list returned.