Cody Bable

Generation

generate functionThu, 13 Apr 2023

list comprehension for dividing a list into three lists and reverse the items in the each of the three lists.

def divide(list): return [list[i::3] for i in range(3)] def reverse(list): return [list[::-1] for i in range(3)] def divide_and_reverse(list): return reverse(divide(list)) list = [1, 2, 3, 4, 5, 6, 7, 8, 9] divide_and_reverse(list)

Questions about programming?Chat with your personal AI assistant