Computer Science, asked by rahulmittal6179, 4 months ago

Write the program to swap the first and last value of a list in python

Answers

Answered by kakawaljeet
0

Answer:

Explanation:

def swap(x,y):

   # create a temporary variable and swap the values

   temp = x

   x = y

   y = temp

   return x,y

list = [1,2,3,4]

x = list[0]

y = list[len(list)]

print(swap(x,y))

Similar questions