Computer Science, asked by TeeshaAhuja, 10 months ago

The program should ask for the position of the

element to be deleted from the list and delete the

element at the desired position in the list.​

Answers

Answered by Equestriadash
9

The following codes are written in Python.

Source code:

l = eval(input("Enter the elements: "))

print(l, "is your given list.")

x = int(input("Enter the position of the element you want to delete: "))

del l[x]

print(l, "is your given list.")

  • del is a method that is used for deleting elements.

This is similar to the pop() function.

The code can be re-written with the pop function as well.

l = eval(input("Enter the elements: "))

print(l, "is your given list.")

x = int(input("Enter the position of the element you want to delete: "))

l.pop(x)

print(l, "is your given list.")

Attachments:
Similar questions