python | February 05, 2020
def merge_and_swap(list1, list2):
if len(list1) == 0 and len(list2) == 0:
return []
else:
new_list = list1 + list2
new_list.append(new_list[0])
new_list[0] = new_list[-2]
new_list.pop(-2)
return new_list
def merge_and_swap(list1, list2):
list1 = list1 + list2
length = len(list1)
if length > 1:
first = list1[0]
last = list1[length - 1]
list1[0] = last
list1[length - 1] = first
return list1
else:
return list1