Write a Python program that takes a number from the user and prints its digits from left to right.
[Consider the input number to be an INTEGER. You are not allowed to use String indexing for solving this task]
=========================================================================
Example: if the user gives 32768, then print 3, 2, 7, 6, 8
num = int(input("Input number: "))
array = []
while (num != 0):
digit = num % 10
num = num // 10
array.append(digit)
for i in range(len(array)-1, 0, -1):
print(f'{array[i]}, ', end='')
print(f'{array[0]}') # Print last digit
Comments
Leave a comment