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

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

Steps to solve the program
  1. Take a list of tuples as input and create an empty list.
  2. Use a for loop to iterate over tuples in the list.
  3. Add the tuples to the empty list using append() after converting them to a list using list().
  4. Print the output.
				
					l = [(1,5),(7,8),(4,0)]
l1 = []
print("Original list: ",l)
for tup in l:
    l1.append(list(tup))
print("After converting tuples inside a list to list: ",l1)
				
			

Output :

				
					Original list:  [(1, 5), (7, 8), (4, 0)]
After converting tuples inside a list to list:  [[1, 5], [7, 8], [4, 0]]
				
			

compute the element-wise sum of tuples.

find all the tuples that are divisible by a number.

Leave a Comment