A
A
asfafveresvr2021-09-05 16:23:02
Python
asfafveresvr, 2021-09-05 16:23:02

How to split a number into digits?

How can I make it so that when you enter a 4-digit number, it is divided into digits?

print('Введите число:')
number = input()

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Developer, 2021-09-05
@samodum

divide by 10 and take the remainder until the dividend is zero.

K
Kudis, 2021-09-06
@kudis

Here is an option without being tied to the system:

your_float = 1234512345.1234
result = '{:,}'.format(your_float).replace(',', ' ')
print(result)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question