Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python - Change List Items

thislist = ["apple", "banana", "cherry"]
thislist[1] = "blackcurrant"
print(thislist)
Comment

change list item in python

#Change the values "banana" and "cherry" with the 
#values "blackcurrant" and "watermelon":

thislist = ["apple", "banana", "cherry", "orange", "kiwi", "mango"]
thislist[1:3] = ["blackcurrant", "watermelon"]
print(thislist)

#Output :['apple', 'blackcurrant', 'watermelon', 'orange', 'kiwi', 'mango']
Comment

List Change a Element

a = [1,2,3]
a[2] = "b"
print(a)
# [1, 2, 'b']
Comment

PREVIOUS NEXT
Code Example
Python :: generate random integers in a range 
Python :: print random integers py 
Python :: delete cell in jupyter notebook 
Python :: python test if list of dicts has key 
Python :: maximum and minimum value of array python 
Python :: python str contains word 
Python :: df to sql mysql 
Python :: python pip Failed to build cryptography 
Python :: making a return from your views 
Python :: legend text color matplotlib 
Python :: python dictionary to list 
Python :: Python NumPy repeat Function Example 
Python :: python remove lines of string 
Python :: how to select rows with specific values in pandas 
Python :: python minigame 
Python :: Video to text convertor in python 
Python :: urllib download file to folder 
Python :: delete column in dataframe pandas 
Python :: python check phone number 
Python :: django pass parameters in url 
Python :: python get pixel 
Python :: how to take space separated input in python 
Python :: catch error in mongo query python 
Python :: how to append panda columns using loop 
Python :: forgot django admin password 
Python :: spark df to pandas df 
Python :: python callable type hint 
Python :: python timeout exception 
Python :: python flask how to remove last character from string 
Python :: Python Overloading the + Operator 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =