Python Program for Adding, removing elements in the list

Here, we will figure out how to add components to the rundown, how to expel components from the rundown in Python?

Given a rundown of the components and we need to include/evacuate components in/from the rundown in Python.

Python List attach() Method:

It is utilized to include/attach an item (which will be passed in strategy as a parameter) to the rundown.

Syntax:

 list.append(element)

Here,

  1. list – is the name of the rundown.
  2. add() – is the technique name, that is utilized to include component/article to the rundown.
  3. component – is a component (which is considered as an article or component) to be included the rundown.

Python List pop() Method:

It is utilized to evacuate/pop an article from the rundown.

Syntax:

 list.pop()

Here,

  • the list is the name of the rundown.
  • pop() is the technique name that is utilized to expel the last component from the rundown.

Leave a Comment

error: Alert: Content is protected!!