Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to update list in python

simple_list = [1,2,3,4]

# append an element
simple_list.append(5) # now simple_list is [1,2,3,4,5]

# append all the elements of another list (NO NESTING)
second_list = [6,7,8]
simple_list.extend(second_list) # now simple_list is [1,2,3,4,5,6,7,8]

# replace an element by simply giving the index and the new element
simple_list[0] = 100 # now simple_list is [100,2,3,4,5,6,7,8]
Comment

list update python

simple_list.extend(second_list)
Comment

Updating lists

#!/usr/bin/python

list = ['physics', 'chemistry', 1997, 2000];
print "Value available at index 2 : "
print list[2]
list[2] = 2001;
print "New value available at index 2 : "
print list[2]
Comment

PREVIOUS NEXT
Code Example
Python :: keep only one duplicate in pandas 
Python :: python call function from string 
Python :: pygame tick time 
Python :: how do i turn a tensor into a numpy array 
Python :: change index of dataframe with list 
Python :: python check tuple length 
Python :: how does urllib.parse.urlsplit work in python 
Python :: solve ax=b python 
Python :: pandas df filter by time hour 
Python :: python format subprocess output 
Python :: concatenate python 
Python :: 3 dimensional array in numpy 
Python :: on progress callback pytube 
Python :: convert float to int python 
Python :: unittest skip 
Python :: twitter api v2 python tweepy 
Python :: How to construct a prefix sum array in python? 
Python :: Python datetime to string using strftime() 
Python :: moving averages python 
Python :: sklearn support vector machine 
Python :: How to wait a page is loaded in Python Selenium 
Python :: how to scrape multiple pages using selenium in python 
Python :: split a text file into multiple paragraphs python 
Python :: how to change the values of a column in numpy array 
Python :: python sort array of dictionary by value 
Python :: python character list to string 
Python :: show all rows for dataframe 
Python :: python read json file array 
Python :: python sort array by value 
Python :: get ip address py 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =