Answers for "how to replace an element of a list using list comprehension"

0

how to replace an element of a list using list comprehension

new_list = ["A" if element == "a" else element for element in a_list]
Posted by: Guest on February-06-2021

Code answers related to "how to replace an element of a list using list comprehension"

Python Answers by Framework

Browse Popular Code Answers by Language