Python program to interchange first and last elements in a list.

 Python program to interchange first and last elements in a list


Code -

--------------------

al = ['First element', 'b', 'c', 'd', 'Just', 'Last element']


def reverse_do():

    print(al)

    a = (len(al))

    b = a - 1

    c = al[b]

    d = al[0]

    al.pop()

    al.remove(d)

    al.append(d)

    al.insert(0, c)

    print(al)



reverse_do()

Comments

Popular posts from this blog

Shopping Bill Generator In python.

Should we start preparation for BCA/MCA from class 11th ? How ?

Python program to check that a list have elements in it or not .