generate functionMon, 13 Feb 2023

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

def remove_elements_while(char_list, char): for i in range(0, len(char_list)): if char_list[i] == char: del char_list[i] break return char_list remove_elements_while(['a', 'b', 'c', 'd', 'e', 'f'], 'd')

Questions about programming?Chat with your personal AI assistant