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

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 :: panda3d intervals 
Python :: How to swapcase of string in python 
Python :: ssd 1306 esp32 python 
Python :: convert set to list python time complexity method 4 
Python :: numpy.floor_divide() in Python 
Python :: change tag name using beautifulsoup python 
Python :: pyhton transpose without changing column and row names 
Python :: Call a function after every x seconds 
Python :: Python script to do something at the same time every day 
Python :: datetime.timedelta 
Python :: os cd python 
Python :: como poner python 3 en la terminal mac 
Python :: stackoverflow Django ForeignKey 
Python :: python iterate through lists 
Python :: Matrix Transpose using Nested Loop 
Python :: python get screen dpi 
Python :: frequency domain parameter of speech 
Python :: how to change pi hostname in python file 
Python :: pyqt stretch image 
Python :: python scrape data from aspx page 
Python :: not staments python 
Python :: hidden semi markov model python from scratch 
Python :: removing an item from a list and adding it to another list python 
Python :: find that are not images in the entire images folder. 
Python :: create a list with user defined name of list 
Python :: pyqt-opengl-drawing-simple-scenes 
Python :: change the Values to Numpy Array 
Python :: Get index for value_counts() 
Python :: how to make an app that sends email in python 
Python :: time for range in python 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =