Write a Python function to interchange first and last elements in a list


Topic: Write a Python function to interchange first and last elements in a list

Solution

def swapList(newList): 
    size = len(newList) 
    temp = newList[0] 
    newList[0] = newList[size - 1] 
    newList[size - 1] = temp 
    return newList
	
	



List all Python Programs