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
Given a list of elements and a value to replace, the task is to update one or more matching values with a new value. For Example: Input: a = [10, 20, 30, 40, 50] and Replace value 30 -> 99 Output: [10, 20, 99, 40, 50]
Published   January 12, 2026
Discussions

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
Hi! I am a newbie. Why doesn't list.replace() work? Help!
Hey! I was working on a text adventure game and was trying to remove a part of dis3 after the player takes the item in isect3(). Here is my code Help = "NO CAPS l=look n=north s=south e=east w=west u=up d=down ew=eastwest take (item) l (item) use (item) r=restart drop (item) take all" inventory ... More on discuss.python.org
🌐 discuss.python.org
4
0
March 19, 2022
How to replace an item in a list without indexing
a = [num if num != int(userinput) else "X" for num in a] More on reddit.com
🌐 r/learnpython
5
2
January 29, 2022
MATLAB function "publish": How to replace it in Python?
I have decided to overwrite my comments. More on reddit.com
🌐 r/learnpython
7
6
April 25, 2018
🌐
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 - When replacing values in a list in Python, it’s important to consider the data types involved. If the new value has a different data type than the original, you may need to perform type conversion. For example, if you want to replace an integer with a string, you can use the `str()` function to convert the integer to a string.
🌐
W3Schools
w3schools.com › python › ref_string_replace.asp
Python String replace() Method
Remove List Duplicates Reverse ... Q&A Python Bootcamp Python Training ... The replace() method replaces a specified phrase with another specified phrase....
🌐
Reddit
reddit.com › r/learnpython › how to replace values in a list?
How to replace values in a list? : r/learnpython
September 26, 2022 - As long as you're not inserting or deleting items from a list, you can use the enumerate function to generate an index for each element in the list. That index can be used to modify an element. board = [] for i in range(3): row = [] for j in range(3): row.append(0) board.append(row) print(board) for row in board: for i, number in enumerate(row): if number == 0: row[i] = " " print(board) ... Starting Python today.
🌐
Python.org
discuss.python.org › python help
Hi! I am a newbie. Why doesn't list.replace() work? Help! - Python Help - Discussions on Python.org
March 19, 2022 - Hey! I was working on a text adventure game and was trying to remove a part of dis3 after the player takes the item in isect3(). Here is my code Help = "NO CAPS l=look n=north s=south e=east w=west u=up d=down ew=eastwest take (item) l (item) use (item) r=restart drop (item) take all" inventory = ['$10 bill'] appearance = "dirty" #1 sect1 = ["l", "n", "s", "l door"] sect2 = ["l", "w", "s", "l shelf"] sect3 = ["l", "n", "s", "e", "w", "l shovel", "l flo...
🌐
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 - # Replace a particular item in a Python list using a function a_list = ['aple', 'orange', 'aple', 'banana', 'grape', 'aple'] def replace_values(list_to_replace, item_to_replace, item_to_replace_with): return [item_to_replace_with if item == item_to_replace else item for item in list_to_replace] replaced_list = replace_values(a_list, 'aple', 'apple') print(replaced_list) # Returns: ['apple', 'orange', 'apple', 'banana', 'grape', 'apple']
Find elsewhere
🌐
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".
🌐
PyTutorial
pytutorial.com › python-list-replace-simple-guide
PyTutorial | Python List Replace: Simple Guide
May 24, 2026 - For simple conditions, list comprehension is usually more readable. If your list contains strings, you can use the string replace() method. This replaces substrings within each string. It does not replace the whole element.
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-replace-values-in-a-list-in-python
How to Replace Values in a List in Python? - GeeksforGeeks
The simplest way to replace values in a list in Python is by using list indexing. Let’s take an example of replacing values in a list using list indexing. ... Let’s see other different methods to Replace Values in a List. ... In this method, we use lambda and map function to replace the value in the list.
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 items in a list using a Python for loop. To do so, we need to the Python enumerate() function. This function returns two lists: the index numbers in a list and the values in a list.
🌐
Interview Kickstart
interviewkickstart.com › home › blogs › learn › the replace() function in python
The replace() Function in Python | Interview Kickstart
September 25, 2024 - We can replace a string in a list in Python by using the replace() function along with a for loop.
🌐
stataiml
stataiml.com › posts › 35_find_replace_string_python_list
Find and Replace Values in List in Python - stataiml
May 3, 2024 - You can find and replace string values in a list using a list comprehension or map() function in Python.
🌐
Python Help
pythonhelp.org › python-lists › how-to-replace-in-a-list-python
How to replace items in a list in Python
# List of items list_items = ['apple', 'banana', 'cherry', 1, 2, 3] # Elements to replace (can be any data type) elements_to_replace = ['apple', 1] # New elements new_elements = ['mango', 4] # Replacing in a list list_items = list(map(lambda x: new_elements[elements_to_replace.index(x)] if x in elements_to_replace else x, list_items)) print(list_items) # ['mango', 'banana', 'cherry', 4, 2, 3] In both examples above, we replace the elements 'apple' and 1 in our original list with 'mango' and 4 respectively.
🌐
Analytics Vidhya
analyticsvidhya.com › home › beginner’s guide to replace() method in python
Beginner’s Guide to replace() Method in Python
April 15, 2024 - A. To replace a value in a variable in Python, you can use the assignment statement. For example, variable_name = new_value assigns the variable with the specified new value, effectively replacing the previous content.
🌐
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 - How to replace values or elements in list in Python? You can replace a list in python by using many ways, for example, by using the list indexing, list
🌐
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 - Replace strings in Python (replace, translate, re.sub, re.subn) List comprehensions offer a simpler alternative to the traditional for loop when creating new lists.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-replace-substring-in-list-of-strings
Replace substring in list of strings - Python - GeeksforGeeks
July 11, 2025 - For example, given a = ["hello ... discuss different methods to do this in Python. replace() method replaces occurrences of a substring in a string....
🌐
Python Guides
pythonguides.com › replace-items-in-a-python-list
How To Replace Values In A List Using Python?
March 19, 2025 - Here, we use map() with a lambda function that checks if each state starts with the letter “M” using the startswith() method. If true, the state is replaced with “Massachusetts”. Otherwise, the original state name is retained. Finally, we convert the result of map() back to a list using the list() function. Check out How to Remove None Values from a List in Python?
🌐
SitePoint
sitepoint.com › python hub › change list items
Python - Change List Items | SitePoint — SitePoint
The simplest way to modify a list element is to use its index and the assignment operator =. ... Here, we replaced the element at index 1 (the second element, since indexing starts at 0) from "banana" to "orange".