Answer:
def swap(lst):
lst = lst.split(",");
temp = lst[0]
lst[0] = lst[-1]
lst[-1] = temp
return lst
lst = input("Enter the list items: ")
print(swap(lst))
Step-by-step explanation:
Create a function named swap that takes one parameter, lst
Since the input is entered as commas between values, we need to split the values using split() function
Set the temp as the first item in the lst
Update the first item as the last item
Update the last item as temp (Note that temp has the initial value of the first item)
Return the list
Ask the user to enter the items
Call the swap function passing the input as parameter and print