16.1k views
1 vote
2.11 (Separating the Digits in an Integer) Write a script that inputs a five-digit integer from the user. Separate the number into its individual digits. Print them separated by three spaces each. python

User Ziggystar
by
8.6k points

1 Answer

1 vote

Answer:

The program in Python is as follows:

number = int(input())

myList = [int(num) for num in str(number)]

for i in myList:

print(i,end=" ")

Step-by-step explanation:

This gets input from the user

number = int(input())

This converts the number to a list (each digit of the number becomes the elements of the list)

myList = [int(num) for num in str(number)]

This iterates through the list

for i in myList:

This prints the list element followed by 3 blank spaces

print(i,end=" ")

User Ariadne
by
7.3k points