Python list: How can I replace certain items of the list?

Spread the love

In this tutorial, you will learn how to replace certain items of the list?

b=[1,2,3,4,5,6,7,8] for n, i in enumerate(b): if i == 1: b[n] = 10 print(b)


[10, 2, 3, 4, 5, 6, 7, 8]

If you have any alternative ways to do it, You can comment below.


Leave a Reply

Your email address will not be published. Required fields are marked *