67.8k views
2 votes
Write a program that reads in an integer, and breaks it into a sequence of individual digits. Display each digit on a separate line. For example, the input 16384 is displayed as 1 6 3 8 4 You may assume that the input has no more than five digits and is not negative.

User Soupdiver
by
3.4k points

1 Answer

3 votes

Answer:

The program in Python is as follows:

num = int(input())

for i in str(num):

print(int(i))

Step-by-step explanation:

This gets input for the number

num = int(input())

This converts the number to string and iterates through each element of the string

for i in str(num):

This prints individual digits

print(int(i))

User DrStrangepork
by
3.2k points