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'))
🌐
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   November 20, 2021
🌐
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.
🌐
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.
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 (:).
🌐
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…
🌐
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
🌐
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', ...
🌐
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.
🌐
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”.
🌐
Python Pool
pythonpool.com › home › blog › 7 efficient ways to replace item in list in python
7 Efficient Ways to Replace Item in List in Python - Python Pool
May 7, 2023 - The while loop shall execute while the value of ‘i’ is less than the length of the list my_list. We shall use the replace() method to replace the list item ‘Gray’ with ‘Green.’ The variable ‘i’ shall be incremented at the end of the loop.
🌐
Altcademy
altcademy.com › blog › how-to-replace-an-item-in-a-list-python
How to replace an item in a list Python
September 4, 2023 - Let's say you want to replace 'eggs' with 'orange' and 'milk' with 'grapes'. Here's how you can do it: my_shopping_list[0], my_shopping_list[1] = "orange", "grapes" This code is telling Python to replace the items at index 0 ('eggs') and index 1 ('milk') with 'orange' and 'grapes', respectively.
🌐
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.