append item in list python code example

Example 1: how to add an item to a list in python

myList = [1, 2, 3]

myList.append(4)

Example 2: add item to list python

list.append(item)

Example 3: append item to array python

data = []
data.append("Item")

print(data)

Example 4: how to add item to a list python

my_list = []
item1 = "test1"
my_list.append(item1)

print(my_list) 
# prints the list ["test1"]

Example 5: using append in python

lst=[1,2,3,4]
print(lst)

#prints [1,2,3,4]

lst.append(5)
print(lst)

#prints [1,2,3,4,5]

Example 6: add an element to list python

a=[8,5,6,1,7]
a.append(9)

Tags:

Misc Example