Cody Bable

Generation

generate functionThu, 13 Apr 2023

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

def split_list(input_list): """ Split a list into 3 evenly sized chunks """ length = int(round(len(input_list) / 3.0)) return [input_list[i * length:(i + 1) * length] for i in range(3)] split_list(['a', 'b', 'c', '1', '2', '3'])

Questions about programming?Chat with your personal AI assistant