• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
August 30, 2022 |430 Views
Python program to Remove None from List
  Share  1 Like
Description
Discussion

In this video, we will write a python program to remove None values from a list.

We will be covering the following methods:
1. Using Naive Method
2. Using filter() function

Method 1: Using Naive Method: 
In this method, we create a new list and then we iterate on each values of the list and compare if the value is not None, then we append the value to our new list. After the iteration is complete, the new list will have all elements of the old list except the None values.

Method 2: Using filter(): 
In this method, we write a lambda function for checking if the a value is not None and use it as the condition inside the filter() Python built-in method and pass the list as the second parameter. Then we convert the return of the filter function to list using list() method. The result will have all the values of the list except the None values.

Python program to remove none values from list:
https://www.geeksforgeeks.org/python-remove-none-values-from-list/

Read More