Computer Science, asked by bulbusaha1234, 3 months ago

Write a program to initialise a list in Python then perform the following operations

number 1 insert a element in the index 2 remove the last element off the list insert

element at the last of the list.​

Answers

Answered by Equestriadash
5

#initializing a list

>>> l = list()

#1

>>> x = eval(input("Enter the element you want to insert: "))

>>> l.insert(2, x)

#2

>>> del l[-1]

  • A list can be initialized by using the list() function or by simply storing an empty list ([]) into the variable.
  • insert() is a method used to insert an element into a list, where the arguments involve the index position and the element to be inserted respectively.
  • del is a function that deletes the specified argument.
Similar questions