How do I append the contents of one list at the end of another list?
You would use: books2. addAll(books); to append all entries in books to books2 .
To append a list to another list, use extend() function on the list you want to extend and pass the other list as argument to extend() function. In this tutorial, we shall learn the syntax of extend() function and how to use this function to append a list to other list.
append() method adds the entire item to the end of the list. If the item is a sequence such as a list, dictionary, or tuple, the entire sequence will be added as a single item of the existing list.
The append() method adds a single element towards the end of a list.
List.addAll()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With