There’s nothing built-in, but it’s just a loop to do the replacement in-place:

for i, word in enumerate(words):
    if word == 'chicken':
        words[i] = 'broccoli'

or a shorter option if there’s always exactly one instance:

words[words.index('chicken')] = 'broccoli'

or a list comprehension to create a new list:

new_words = ['broccoli' if word == 'chicken' else word for word in words]

any of which can be wrapped up in a function:

def replaced(sequence, old, new):
    return (new if x == old else x for x in sequence)


new_words = list(replaced(words, 'chicken', 'broccoli'))
Discussions

Making str.replace() accept lists - Ideas - Discussions on Python.org
Syntax of the method: str.replace(old, new, count=-1) What if replace could accept two lists instead of two strings. Often I find in code: text.replace(a, b).replace(c, d) The concatenation of replace calls can cause a unnecessary performance hit if the string is large or the call is the calls ... More on discuss.python.org
🌐 discuss.python.org
3
May 9, 2020
How to replace values in a list?
number is different from board. Print the id for each. for row in board: for number in row: if board[row][number]== 0: board[row][number]=" " More on reddit.com
🌐 r/learnpython
6
0
September 26, 2022
Hello, is there a way to mutate strings in Python?
As a technical issue, you cannot "mutate" strings (change them in-place), so string operations always must return a new string if the result differs from the original. And besides the str.replace() method mentioned, there is str.translate() for doing multiple character remappings in one pass, and the codecs module if you really need more flexibility in customized mappings. More on reddit.com
🌐 r/learnpython
8
3
December 20, 2020
Why no .get(idx[, default]) on python list??
There was a lengthy thread on this on Python-Ideas a couple of years ago: https://mail.python.org/archives/list/python-ideas@python.org/thread/LLK3EQ3QWNDB54SEBKJ4XEV4LXP5HVJS/ The clearest explanation of the most common objection was from Marc-Andre Lemburg: dict.get() was added since the lookup is expensive and you want to avoid having to do this twice in the common case where the element does exist. It was not added as a way to hide away an exception, but instead to bypass having to generate this exception in the first place. dict.setdefault() has a similar motivation. list.get() merely safes you a line of code (or perhaps a few more depending on how you format things), hiding away an exception in case the requested index does not exist. If that's all you want, you're better off writing a helper which hides the exception for you. I argue that making it explicit that you're expecting two (or more) different list lengths in your code results in more intuitive and maintainable code, rather than catching IndexErrors (regardless of whether you hide them in a method, a helper, or handle them directly). So this is more than just style, it's about clarity of intent. More on reddit.com
🌐 r/Python
94
144
June 21, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-replace-values-in-a-list-in-python
Replace Values in a List in Python - GeeksforGeeks
For Example: Input: a = [10, 20, 30, 40, 50] and Replace value 30 -> 99 Output: [10, 20, 99, 40, 50] This method replaces a value by directly accessing a specific position in the list and assigning a new value to that position.
Published   January 12, 2026
🌐
Analytics Vidhya
analyticsvidhya.com › home › how to replace values in a list in python?
How to Replace Values in a List in Python? - Analytics Vidhya
April 23, 2025 - You can easily replace values in a list based on specific conditions or requirements by utilizing various methods such as loops, list comprehension, built-in functions, and the map function.
🌐
W3Schools
w3schools.com › python › python_lists_change.asp
Python - Change List Items
To insert a new list item, without replacing any of the existing values, we can use the insert() method.
🌐
datagy
datagy.io › home › python posts › python: replace item in list (6 different ways)
Python: Replace Item in List (6 Different Ways) • datagy
August 12, 2022 - Learn how to replace an item or items in a Python list, including how to replace at an index, replacing values, replacing multiple values.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Extract and Replace Elements That Meet the Conditions of a List of Strings in Python | note.nkmk.me
May 19, 2023 - Extract, replace, convert elements of a list in Python · l_replace_all = ['ZZZ' if 'XXX' in s else s for s in l] print(l_replace_all) # ['ZZZ', 'ZZZ', 'three999aaa', '000111222'] ... Parentheses can enhance code readability and reduce potential errors, although their usage is grammatically optional. ... The startswith() method returns True if the string starts with the specific string.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › python-program-to-replace-elements-in-a-list
Python Program to Replace Elements in a List
# first define a list list_1 = ['REALME', 'REDME', 'APPLE', 'VIVO'] i = 3 while i < len(list_1): # replace VIVO with OPPO from the list if list_1[i] == 'VIVO': list_1[i] = 'OPPO' i += 1 print(list_1) ... In Python, you must slice a list in order to access a specific subset of its elements. Use of the colon, a simple slicing operator, is one method for accomplishing this (:).
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-replace-values-in-a-list-in-python
How to Replace Values in a List in Python? - GeeksforGeeks
In this method, we use lambda and map function to replace the value in the list. map() is a built-in function in python to iterate over a list without using any loop statement. A lambda is an anonymous function in python that contains a single ...
Published   January 4, 2025
🌐
Career Karma
careerkarma.com › blog › python › replace item in list in python: a complete guide
Replace Item in List in Python: A Complete Guide: A Complete Guide
December 1, 2023 - You can replace an item in a Python list using a for loop, list indexing, or a list comprehension. The first two methods modify an existing list whereas a list comprehension creates a new list with the specified changes.
🌐
W3Schools
w3schools.com › python › ref_string_replace.asp
Python String replace() Method
Python Overview Python Built-in ... Python Certificate Python Training ... The replace() method replaces a specified phrase with another specified phrase....
🌐
Python.org
discuss.python.org › ideas
Making str.replace() accept lists - Ideas - Discussions on Python.org
May 9, 2020 - Syntax of the method: str.replace(old, new, count=-1) What if replace could accept two lists instead of two strings. Often I find in code: text.replace(a, b).replace(c, d) The concatenation of replace calls can cause…
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python replace values in list with examples
Python Replace Values in List With Examples - Spark By {Examples}
May 31, 2024 - You can then use list slicing to replace the item at this index with a new value, which is ‘Salesforce‘. The above example yields the below output. # Output: ['Spark', 'Python', ...
🌐
Quora
quora.com › Python-list-how-can-I-replace-certain-items-of-the-list
Python list: how can I replace certain items of the list? - Quora
Replacing items in a Python list can be done in several ways depending on which items you want to change: by index, by slice (contiguous range), by value (all or first occurrences), by condition, or by mapping.
🌐
Ceos3c
ceos3c.com › home › python › python list replace – simple & easy
Python List Replace - Simple & Easy
March 1, 2023 - for index, color in enumerate(favorite_colors): if color == "Gray": favorite_colors[index] = "Beige" print(favorite_colors)Code language: Python (python) ... This way, we utilize a for loop in combination with the enumerate() function to locate the color "Gray" and replace it with the color "Beige". Breaking this down, the enumerate() function requires three things: ... The loop then runs over each item of our list and checks if the color is, in fact, "Gray". If that is the case, we use the same principle as in Method 1 to replace that item at the current index with our new color "Beige".
🌐
YouTube
youtube.com › watch
List Replace Python - The EASIEST Methods - YouTube
Python is a powerful programming language that can be used for all sorts of things. In this video, we're going to show you how to use list replace python to ...
Published   September 6, 2022
🌐
Python Guides
pythonguides.com › replace-items-in-a-python-list
How To Replace Values In A List Using Python?
March 19, 2025 - Learn how to replace values in a list using Python with methods like indexing, list comprehension, and `map()`. This guide includes step-by-step examples.
🌐
SitePoint
sitepoint.com › python hub › change list items
Python - Change List Items | SitePoint — SitePoint
Here, we created a DefaultList class that automatically fills the list with default values (0) if an index beyond the current length is accessed. Now you know how to replace individual elements by index, work with ranges using slices, reorder elements with methods like reverse() and sort(), and combine modifications with calculations.
🌐
Replit
replit.com › home › discover › how to replace an element in a list in python
How to replace an element in a list in Python | Replit
5 days ago - The most direct method for replacing a list item is through index assignment. The expression fruits[1] = 'blueberry' targets the element at index 1 and overwrites its value directly.
🌐
Enterprise DNA
blog.enterprisedna.co › how-to-replace-an-element-in-list-python
How to Replace an Element in List Python: Step-by-Step Guide – Master Data Skills + AI
This Python code is used to find the index position of a specific element in a list. It first uses the .index() method to locate the index position of “banana” in the ‘fruits’ list, and assigns this value to the variable ‘target_index’. Then, it uses this index to replace the found element “banana” with “mango”. Therefore, if “banana” was on the list, its position would be changed to “mango”.