Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python replace all in list

def ReplaceAllInList(list, lookupvalue, replacewith):
    return [(replacewith if v == lookupvalue else v) for v in list]

a = ['aaa', 'bb', 'bb']
a = ReplaceAllInList(list= a, lookupvalue= 'bb', replacewith= 'cc')
print(a)  # output --> ['aaa', 'cc', 'cc']
 
PREVIOUS NEXT
Tagged: #python #replace #list
ADD COMMENT
Topic
Name
5+3 =