To append multiple elements to a list in Python, you can use the extend
method or the +
operator.
Here is an example using the extend
method:
main.py89 chars5 lines
Output:
main.py19 chars2 lines
And here is an example using the +
operator:
main.py84 chars5 lines
Output:
main.py19 chars2 lines
Both methods will modify the original list by adding all the elements from the new elements list at the end.
gistlibby LogSnag