Remove tuples from the List having an element as None

In this python tuple program, we will remove tuples from the List having an element as None.

Steps to solve the program
  1. Take a list of tuples as input.
  2. Use for loop to iterate over tuples in the list.
  3. Use another nested loop to iterate over elements in the tuples.
  4. In an element in the tuple is equal to None then remove that tuple from the list.
  5. Print the output.
				
					l =  [(None,),(5, 4),(1,6,7),(None,1)]
print("Origianl list: ",l)
for tup in l:
    for ele in tup:
        if ele == None:
            l.remove(tup)

print("After removing tuples: ",l)
				
			

Output :

				
					Origianl list:  [(None,), (5, 4), (1, 6, 7), (None, 1)]
After removing tuples:  [(5, 4), (1, 6, 7)]
				
			

remove tuples of length i.

remove Tuples from the List having every element as None.

Leave a Comment