List append is used to append element in the list in python. for an instance a is list as shown below write a. press tab after typing dot(.)

Example of Python List.Append():

a=[‘apple’,’orange’,’mango’]

To append element in List

a.append(“guavava”)

append element in list using list.append
1.Append Element in List

and element will be added in list.

when we try to append 2 items in list it will throw error

Error:list.append() takes exactly one argument (2 given)
To solve this we have to make list of element which we want to add then we can either use List.extend function in python or it can be done by just simple adding two list.for example.

If a and b are two list.

a=[‘a’,’b’]

b=[‘v’,’c’]

now we have to append element of b to a. for this we just simple write a+b as shown in image below.

2.List append in python throw error it takes only one argument two given
2.List append in python Error Resolution

Element of list b will be appended to list a.

 

By SC

2 thoughts on “List.append”

Leave a Reply

Your email address will not be published. Required fields are marked *