Python Practice › Tuple Programs › Program 44
Tuple of digits to a number
Write a Python program to convert a tuple of digits into a number.
Input
(4, 5, 3, 8)
Output
4538
Approach
- Build the number with
n * 10 + digit.
Solution
number = 0for d in (4, 5, 3, 8): number = number * 10 + dprint(number)Output
4538
Learn the concept
New to this topic? Read the lesson, then come back.