Program to return an empty set if no tuples are symmetrical

In this python tuple program, we will return an empty set if no tuples are symmetrical.

Steps to solve the program
				
					l = [(1, 5), (3, 4), (4, 9)]
print("Original list of tuples: ",l)
temp = set(l) & {(b, a) for a, b in l}
sym = {(a, b) for a, b in temp if a < b}
print("Tuples that are symmetric: ",sym)
				
			

Output :

				
					Original list of tuples:  [(1, 5), (3, 4), (4, 9)]
Tuples that are symmetric:  set()
				
			

extract tuples that are symmetrical with others from a list of tuples.

remove nested elements from a tuple.

Leave a Comment