Generation

code to explanationThu, 27 Apr 2023

def swap_list(new_list): new_list[0], new_list[-1] = new_list[-1], new_list[0] return new_list new_list = [12, 35, 9, 56, 24] swap_list(new_list)

The function swap_list takes a list of items as input and swaps the first and last items in the list.

Questions about programming?Chat with your personal AI assistant