Source Code:
(back to article)
my_list = [1, 2, 3, 4, 5, 3] new_list = [x if x != 3 else 6 for x in my_list] print(new_list) # [1, 2, 6, 4, 5, 6]
Result:
Report an issue