Answers for "add object to list python"

2

python insert object into list

# list.insert(before, value)
list = ["a", "b"]
list.insert(1, "c")
print(list)     	# ['a', 'c', 'b']
# at the end: list.append(value)
list.append("d")	# ['a', 'c', 'b', 'd']
Posted by: Guest on May-13-2021
0

add an element to list python

a=[8,5,6,1,7]
a.append(9)
Posted by: Guest on May-31-2020

Python Answers by Framework

Browse Popular Code Answers by Language