Program to convert a list of lists to a tuple of tuples

In this python tuple program, we will convert a list of lists to a tuple of tuples.

Steps to solve the program
  1. Take a list of lists as input and create an empty list.
  2. Use a for loop to iterate over lists in the list.
  3. Add the list to the empty list using append() after converting it to a tuple using tuple().
  4. Now convert the new list to a tuple using tuple().
  5. Print the output.
				
					l = [['sqatools'],['is'],['best']]
print("List of lists: ",l)
l1 = []
for lists in l:
    l1.append(tuple(lists))
tup = tuple(l1)
print("Tuple of tuples: ",tup)
				
			

Output :

				
					List of lists:  [['sqatools'], ['is'], ['best']]
Tuple of tuples:  (('sqatools',), ('is',), ('best',))
				
			

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

Leave a Comment