Cody Bable

Generation

generate functionThu, 13 Apr 2023

divide list ['a', 'b', 'c', '1', '2', '3'] into three separate list

def split(list): list1 = [] list2 = [] list3 = [] for i in range(len(list)): if i < len(list)//3: list1.append(list[i]) elif i < len(list) * 2 // 3: list2.append(list[i]) else: list3.append(list[i]) return list1, list2, list3 split(['a', 'b', 'c', '1', '2', '3'])

Questions about programming?Chat with your personal AI assistant