Erdinc Ay
0
Q:

how to add an item to a list python

list.append(item)
12
myList = [1, 2, 3]

myList.append(4)
6
my_list = []
item1 = "test1"
my_list.append(item1)

print(my_list) 
# prints the list ["test1"]
5
names = [yaron,roni]
names.append(abram)
6
numbers = [1, 2, 3, 4]
numbers.append(10)
print(numbers)
1
food = "banana"
basket = []

basket.append(food)
0
# to add an item to a list
list.append(item)

# To extend an list with a new list
list1.extend(list2)
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