Q:

add to python list

list_to_add.append(item_to_add)
40
list_to_add.append(item_to_add)
# or
list_to_add.push(item_to_add)
5
a=[1,2,3,4]

a+=[5,6]
1
#append to list
lst = [1, 2, 3]
li = 4
lst.append(li)
#lst is now [1, 2, 3, 4]

.append("the add"): append the object to the end of the list.
.insert("the add"): inserts the object before the given index.
.extend("the add"): extends the list by appending elements from the iterable.
0
food = "banana"
basket = []

basket.append(food)
0
a=[8,5,6,1,7]
a.append(9)
1
a_list = [1,2,3]
a_list.append(4)
0

New to Communities?

Join the community