kelvin
0
Q:

python push to list

list_to_add.append(item_to_add)
40
list.append(item)
12
myList = [apples, grapes]
fruit = input()#this takes user input on what they want to add to the list
myList.append(fruit)
#myList is now [apples, grapes, and whatever the user put for their input]
9
my_list = []
item1 = "test1"
my_list.append(item1)

print(my_list) 
# prints the list ["test1"]
5
list = []
list.append(var)
4
append(): append the object to the end of the list.
insert(): inserts the object before the given index.
extend(): extends the list by appending elements from the iterable.
4
numbers = [1, 2, 3, 4]
numbers.append(10)
print(numbers)
1
a=[8,5,6,1,7]
a.append(9)
1

New to Communities?

Join the community