Cody Bable

Generation

generate functionThu, 13 Apr 2023

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

def divide(lst, n): return [lst[i*n:(i+1)*n] for i in range(len(lst)/n)] divide(['a', 'b', 'c', '1', '2', '3'], 2)

Questions about programming?Chat with your personal AI assistant