Convert a tuple into a list by adding the string after every element of the tuple

In this python tuple program, we will convert a tuple into a list by adding the string after every element of the tuple.

Steps to solve the program
  1. Take a tuple and a string as input.
  2. Create an empty list.
  3. Use a for loop to iterate over elements in the tuple.
  4. Add the element and the string to the empty list using append().
  5. Repeat the process for all elements.
  6. Print the output.
				
					a = (1,2,3,4)
print("Tuple: ",a)
b= 'sqatools'
print("String: ",b)
l = []
for ele in a:
    l.append(ele)
    l.append(b)
				
			

Output :

				
					Tuple:  (1, 2, 3, 4)
String:  sqatools
New list:  [1, 'sqatools', 2, 'sqatools', 3, 'sqatools', 4, 'sqatools']
				
			

flatten a tuple list into a string.

Leave a Comment