Python list append

Python List Append Method

The append method helps us append some elements to the list. By append, we mean that we are adding the element to the end of the list. Let’s have a look at a simple program, that demonstrates about using the append method in our program.

As you can see in the above program, we have the list, which has the names of some fruits. Now, Let’s say that we want to append another name of fruit into the list, we can simply do it using the append method. You can see in the example, how are we using the append method on the list. With the append method, we have to pass what we want to append. It can be some item, like some number, or some string, or some list, etc., that you want to add to the end of the list.

Python List Append Method

So, with the append method, we are adding some items to the end of the list. Note that this method does not return anything.

Let’s also have a look at another program, which demonstrates adding another list to a list.

As you can see in the above program, we have a list of names of fruits, and then we also have a list of some more names of fruits, and we are trying to append a list, to another list. Let’s have a look at the output now –

[‘Apple’, ‘Kiwi’, ‘Guava’, [‘Strawberry’, ‘Orange’, ‘Tamarind’]]

You can see in the output, that the list more_fruit’s is added to the list fruit’s, as a single item. So, we can make use of the append method as and when required, in our Python programs. Note that this method as well, returns None.