python add list items code example

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

myList = [1, 2, 3]

myList.append(4)

Example 2: how to add item to a list python

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

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

Example 3: python add item to list

# to add an item to a list
list.append(item)

# To extend an list with a new list
list1.extend(list2)

Example 4: how to add an item to a list python

numbers = [1, 2, 3, 4]
numbers.append(10)
print(numbers)

Example 5: add items to list python

list.append()

Example 6: add a list in python

list_of_names=["Bill", "John", "Susan", "Bob", "Emma","Katherine"]
new_name="James"
list_of_names.append(new_name)
# The list is now ["Bill", "John", "Susan", "Bob", "Emma","Katherine", "James"]