Contact: aviboots(AT)netvision.net.il
39,939 questions
51,876 answers
573 users
lst = ["a", "b", "c", "c", "b", "d", "e"] result = [i + 1 if x == "b" else x for i, x in enumerate(lst)] print(result) ''' run: ['a', 2, 'c', 'c', 5, 'd', 'e'] '''