Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

replace in lists py

# Replace a particular item in a Python list
a_list = ['aple', 'orange', 'aple', 'banana', 'grape', 'aple']
for i in range(len(a_list)):
    if a_list[i] == 'aple':
        a_list[i] = 'apple'
print(a_list)
# Returns: ['apple', 'orange', 'apple', 'banana', 'grape', 'apple']
Source by datagy.io #
 
PREVIOUS NEXT
Tagged: #replace #lists #py
ADD COMMENT
Topic
Name
8+8 =