generate functionMon, 13 Feb 2023

remove elements through a loop while equal to specific character from python list

def remove_elements(my_list, char): new_list = [] for i in my_list: if i != char: new_list.append(i) return new_list my_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] remove_elements(my_list, 'e')

Questions about programming?Chat with your personal AI assistant