Write a python program that returns a new list where all even numbers are replaced with the string “even“

def func(lst):
    new_list = []
    for i in lst:
        if i%2 == 0:
            new_list.append('even')
        else:
            new_list.append(i)
            
    return new_list

print(func([2, 5, 4, 7, 10, 8]))


Follow on:
  • Twitter
  • Facebook
  • Instagram
  • Linkedin
  • Linkedin
Sunil Shaw

Sunil Shaw

  • Youtube
  • Instagram
  • Twitter
  • Facebook
About Author

I am a Web Developer, Love to write code and explain in brief. I Worked on several projects and completed in no time.

Related Page