Cody Bable

Generation

generate functionThu, 13 Apr 2023

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

def partition(my_list, num_buckets): bucket_size = len(my_list) // num_buckets buckets = [] for bucket_index in range(num_buckets): start = bucket_index * bucket_size end = start + bucket_size buckets.append(my_list[start:end]) return buckets

Questions about programming?Chat with your personal AI assistant