Cody Bable

Generation

generate functionThu, 13 Apr 2023

divide this ['a', 'b', 'c', '1', '2', '3','4', '5', '6'] evenly into three separate list into one single list

def list_splitting(list_of_items): list_of_list = [] for x in range(0, len(list_of_items), 3): single_list = list_of_items[x:x+3] list_of_list.append(single_list) return list_of_list list_splitting(['a', 'b', 'c', '1', '2', '3', '4', '5', '6'])

Questions about programming?Chat with your personal AI assistant