Is it possible to use append on two lists?

new_list = lst1 + lst2

instead of writing the code as above under the definition, is it also possible to use .append on both like these?

new_list.append(lst1, lst2)

if not, what’s the reason?

That works so long as both objects are lists. The plus operator (+) is a concatenation tool for combining lists into one.

Have you tried this? What did you get? Let me guess, an exception was raised since append can only take one argument at a time?

If we append a list to a list, we get a list in a list.

>>> s = []
>>> s.append([])
>>> s
[[]]
>>> 

Conclusion? Concatenating two lists is the simplest approach.

return sorted(lst1 + lst2)
1 Like