Program to extract digits from a list of tuples

In this python tuple program, we will extract digits from a list of tuples.

Steps to solve the program
				
					import re
l = [(6,87,7),(4,53),(11,28,3)]
print("Original list of tuples: ",l)
temp = re.sub(r'[\[\]\(\), ]', '', str(l))
result = [int(ele) for ele in set(temp)]
print("Digits in the list of tuples: ",result)
				
			

Output :

				
					Original list of tuples:  [(6, 87, 7), (4, 53), (11, 28, 3)]
Digits in the list of tuples:  [6, 8, 5, 4, 7, 3, 1, 2]
				
			

remove duplicates from a tuple.

multiply ith element from each tuple from a list of tuples.

1 thought on “Program to extract digits from a list of tuples”

Leave a Comment