py list add code example

Example 1: python add to list

list_to_add.append(item_to_add)

Example 2: add to python list

array.append(element)

Example 3: add to list python

fruits = ["Apple", "Banana"]

# 1. append()
print(f'Current Fruits List {fruits}')

f = input("Please enter a fruit name:\n")
fruits.append(f)

print(f'Updated Fruits List {fruits}')

Example 4: 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"]