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 devide_list_into_three(my_list): return [my_list[:4][::-1], my_list[4:8][::-1], my_list[8:12][::-1]] my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] print(devide_list_into_three(my_list))

Questions about programming?Chat with your personal AI assistant