Q. Write a program to read a list of elements. Input an element from the user that has to be inserted in the list. Also input the position at which it is to be inserted. Write a user defined function to insert the element at the desired position in the list.


Answer :- 


def pathwalla( elem , pos ):
    lst.insert( pos , elem )
    return lst

lst = eval(input("Enter a list :-"))
element = int(input("Enter a element :-"))
position = int(input("Enter its position :-"))

print("New List :-", pathwalla( element, position ))

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post