Answers for "how to insert an object in to a list"

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

Code answers related to "how to insert an object in to a list"

Python Answers by Framework

Browse Popular Code Answers by Language