Answers for "change list item in python"

1

Python - Change List Items

thislist = ["apple", "banana", "cherry"]
thislist[1] = "blackcurrant"
print(thislist)
Posted by: Guest on February-28-2021
1

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']
Posted by: Guest on March-01-2022
0

List Change a Element

a = [1,2,3]
a[2] = "b"
print(a)
# [1, 2, 'b']
Posted by: Guest on December-10-2021

Python Answers by Framework

Browse Popular Code Answers by Language