convert a given tuple of integers into a number

In this python tuple program, we will convert a given tuple of integers into a number.

Steps to solve the program
  1. Take a tuple of integers as input and create an empty string.
  2. Use a for loop to iterate over integers from the tuple.
  3. Add integers to the string after converting them to string datatype using str(), so that we can convert them into a single number.
  4. Print the output.
				
					tup = (4,5,3,8)
str1 = ""
print("Original tuple: ",tup)
for val in tup:
    str1 += str(val)
num = int(str1)
print("Integer: ",num)
				
			

Output :

				
					Original tuple:  (4, 5, 3, 8)
Integer:  4538
				
			

convert a tuple of string values to a tuple of integer values.

compute the element-wise sum of tuples.

Leave a Comment