Answers for "add values to list in python"

1

add to a list python

#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.
Posted by: Guest on November-22-2020
0

add an element to list python

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

Code answers related to "add values to list in python"

Python Answers by Framework

Browse Popular Code Answers by Language