# PS-31 WAP to Swap the First and Last value of a list

def swap_first_n_last_val(li):
    first_val = li[0]
    last_val = li[-1]

    #adding last val to the first pos
    li[0] = last_val
    #adding first val to the last pos
    li[-1] = first_val

    return li


li = [0,1,2,3,4,5,6,7,8,9]

print("Before swap:\n",li)
print("After swap:\n",swap_first_n_last_val(li))



d1f0c97d6aaa73dde1f8be5a173deb9629aac3b4
<mask token>

def swap_first_n_last_val(li):
    first_val = li[0]
    last_val = li[-1]
    li[0] = last_val
    li[-1] = first_val
    return li


<mask token>

def swap_first_n_last_val(li):
    first_val = li[0]
    last_val = li[-1]
    li[0] = last_val
    li[-1] = first_val
    return li


<mask token>
print('Before swap:\n', li)
print('After swap:\n', swap_first_n_last_val(li))

def swap_first_n_last_val(li):
    first_val = li[0]
    last_val = li[-1]
    li[0] = last_val
    li[-1] = first_val
    return li


li = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print('Before swap:\n', li)
print('After swap:\n', swap_first_n_last_val(li))

# PS-31 WAP to Swap the First and Last value of a list

def swap_first_n_last_val(li):
    first_val = li[0]
    last_val = li[-1]

    #adding last val to the first pos
    li[0] = last_val
    #adding first val to the last pos
    li[-1] = first_val

    return li


li = [0,1,2,3,4,5,6,7,8,9]

print("Before swap:\n",li)
print("After swap:\n",swap_first_n_last_val(li))


