Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

add element to list python

my_list=[0,1,2,3]
new_element=700
new_list=[4,5,6]
#if you want add at the end of list:
my_list.append(new_element)
#if you want add a list merge two lists:
my_list.extend(new_list)
#if you want to add element in a specific index
my_list.insert(index , new_element)
Source by w3programmers.org #
 
PREVIOUS NEXT
Tagged: #add #element #list #python
ADD COMMENT
Topic
Name
3+7 =