In this Python lesson we will focus on python Append() method and we will see how to do Python list add. In other words we will learn how to put a new member at the end of the list. Here, we will use append method to do this.
Let’s do an example for python list add function and learn this method better.
With this code, a new string member will be in our string list.
You can also learn Python List Reverse Sort
Let’s do the similar example with a number list.
For this code, the output of this number list will be like below:
We can also put one string list into other string list with this append method. In the below example, we will ad done string list in another string list.
The output of this python code will be like below:
Now let’s do the same python list append example with numbers.
The output of this list append example will be:
As you can see above, the second list (numbers2) is showed as a new member of the first list. And the second list is added at the end of the first list (numbers1). This is different than combining two different strings. Because, here, the second list (numbers2) is only a different member of the first list (numbers1). The members of the second list (numbers2) is not added to the first list (numbers1)one by one.
In this python list add lesson, we have learned how to put a member at the end of a list. We are using python append function to add a member at the end of a list. You can do different python list examples to learn this method better. It is a very popular and one of the most used python methods. Good luck!