Skip to content
Home » Python Programs » Python Program to Remove Elements From a List

Python Program to Remove Elements From a List

Simple python program to remove elements from a list .All of the elements in a list are enclosed in square brackets [] and separated by commas. It can include an unlimited number of elements of various categories. Another list can be included as an item in a list. This is referred to as a nested list.

List in Python

Multiple items can be stored in a single variable using lists. Lists are one of four built-in Python data structures for storing collections of data; the other three are Tuple, Set, and Dictionary, all of which have different properties and applications.

Uses of List in Python

When you need to work with a large number of connected values, lists are ideal. They allow you to keep data that belongs together, simplify your code, and apply the same methods and actions to several variables at the same time.

Declare List Elements in Python

A list is generated in Python programming by putting all the entries inside square brackets [] and separating them with commas. It can contain any number of objects of various types, including integer, float, string, and char. Another list can be included as an item in a list.

Remove Function in Python

The remove() method in the Python programming language removes a given object from a list. It doesn’t give you anything. The method does not return a value, but it does remove the specified object from the list. Using this remove function here we have executed the python program to remove elements from a list.

Python Program to Remove Elements From a List

fruits = ['mango','banana','watermelon']
fruits.remove('mango')
print('Updated fruits ', fruits)

Output:

Update fruits [banana,watermelon]