list comprehension replace python code example
Example: how to replace an element of a list using list comprehension
new_list = ["A" if element == "a" else element for element in a_list]
new_list = ["A" if element == "a" else element for element in a_list]