This can be done quite easily if you:

  1. Use str to convert the number into a string so that you can iterate over it.

  2. Use a list comprehension to split the string into individual digits.

  3. Use int to convert the digits back into integers.

Below is a demonstration:

>>> n = 43365644
>>> [int(d) for d in str(n)]
[4, 3, 3, 6, 5, 6, 4, 4]
>>>
Answer from user2555451 on Stack Overflow
🌐
w3resource
w3resource.com › python-exercises › list › python-data-type-list-exercise-234.php
Python: Convert a given number (integer) to a list of digits - w3resource
# Define a function 'digitize' that takes an integer 'n' as input. def digitize(n): # Convert the integer 'n' to a string, map each character to an integer, and create a list of those integers. return list(map(int, str(n))) # Call the 'digitize' ...
Discussions

How to split int into digits?
x = 19 digits = str(x) And maybe that's enough, because a string is a sequence which can be indexed, sliced, looped. But if you need it to be a list then you could do digits = list(str(x)) instead. Or maybe you want integers for the items in the list? Then it'd have to be like digits = [int(digit) for digit in str(x)] More on reddit.com
🌐 r/learnpython
5
4
January 22, 2023
Splitting a number into its component digits without quotations or commas
My teacher suggested using // and % to do it but I don’t know how to apply that. Keep in mind that your teacher wants you to learn things. Without any doubt someone will post a complete solution that you can copy and paste. And you'd learn nothing. Learning to Code is not just tying words together that the interpreter understands, it's also learning to solve problems. In a number, each digit going left represents a value 10× larger than the digit to the right What does % do exactly? Could you write some code that shows the result of 54321 % 10? And the result of 5432 % 10? What does // do? Could you write some code that shows what the result is of 54321 // 10? Or 5432 // 10? With what you've ;earned with these experiments, do you think you'd be able to extract digit by digit (without treating the number as a string of characters)? More on reddit.com
🌐 r/learnpython
15
7
March 29, 2024
python - Converting integer to digit list - Stack Overflow
Takes an integer as input and converts it into list of digits. ... The question requires it to convert to [1,5,6,7,8,9] and not ['1', '5', '6', '7', '8', '9']. A list of integer has to be returned, your solution returns a list of characters of number. More on stackoverflow.com
🌐 stackoverflow.com
in python how do I convert a single digit number into a double digits string? - Stack Overflow
So say I have a = 5 I want to print it as a string '05' More on stackoverflow.com
🌐 stackoverflow.com
🌐
LabEx
labex.io › tutorials › convert-number-to-digit-list-in-python-13623
Python Digit Conversion | Number to List of Digits | Lab | LabEx
In this challenge, you have learned how to convert a number into a list of its digits using Python. By using the map() function and the int function, you can easily convert each character in a string to an integer and return a list of those integers.
🌐
Delft Stack
delftstack.com › "delft stack" › "howto" › "python tutorial: how-to guides for everyday python problems" › "how to split an integer into digits in python"
How to Split an Integer Into Digits in Python | Delft Stack
February 14, 2024 - A list comprehension is the most ... of digits in their usual left-to-right order. str() exposes one character per decimal digit, and int() converts each character into an integer....
🌐
Bobby Hadz
bobbyhadz.com › blog › python-split-integer-into-digits
How to Split an Integer into Digits in Python | bobbyhadz
You can also use the math.ceil() and math.log() methods if you need to split the integer into digits without converting to a string. ... Copied!import math an_int = 13579 x = math.log(an_int, 10) y = math.ceil(x) list_of_digits = [(an_int//(10**i)) ...
🌐
Python Guides
pythonguides.com › split-a-number-into-digits-in-python
How to Split a Number into Digits in Python?
March 19, 2025 - One simple approach to split a number into digits is to convert the number to a string and then access each character individually.
Find elsewhere
🌐
Ancisoft
ancisoft.com › blog › turn-a-single-number-into-single-digits-python
How to Convert a Number into Single Digits in Python and Append to a List — ancisoft.com
Method 1: String Conversion with ... digits from a number is to convert the number to a string, iterate over its characters (which represent individual digits), convert each character back to an integer, and collect these integers into a list....
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-convert-number-to-list-of-integers
Python - Convert Number to List of Integers - GeeksforGeeks
list comprehension iterates over each character of the string, converts it to an integer, and adds it to the list. A while loop can be used to manually extract digits from the number and store them in a list.
Published: July 11, 2025
🌐
TutorialsPoint
tutorialspoint.com › article › convert-number-to-list-of-integers-in-python
Convert number to list of integers in Python
March 15, 2026 - number = 1342 # Given number print("Given number:", number) # Convert to list of digits using list comprehension digits_list = [int(digit) for digit in str(number)] # Result print("List of digits:", digits_list)
🌐
DEV Community
dev.to › jabermudez11 › splitting-a-number-into-individual-digits-python-3g8a
Splitting a Number into Individual Digits Python - DEV Community
December 6, 2020 - Report Abuse · Justin Bermudez · Posted on Dec 6, 2020 · #beginners #python · If you are looking only for the code then here it is · number = 12345 numList = [int(digit) for digit in str(number)] numList in this example would return [1, ...
🌐
Finxter
blog.finxter.com › home › learn python blog › 5 best ways to convert an integer to a list of digits in python
5 Best Ways to Convert an Integer to a List of Digits in Python - Be on the Right Side of Change
February 18, 2024 - This code snippet converts the integer 1234 into a string, and then creates a map object that applies the int function to each character. The final list is created by passing the map object to the list function. List comprehension offers a more Pythonic way of writing the conversion in a single readable line.
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › python-convert-numeric-words-to-numbers
Convert numeric words to numbers - GeeksforGeeks
July 12, 2025 - DSA Python · Last Updated : 12 Jul, 2025 · The goal is to convert numeric words (such as "zero", "one", "two", etc.) into their corresponding digit forms (e.g., "0", "1", "2") to facilitate numerical operations. For example, in the string "zero four zero one", we aim to convert it into the string "0401".
🌐
PyPI
pypi.org › project › text2num
text2num · PyPI
Parse and convert numbers written in French, Spanish, English, Portuguese, German, Dutch, Danish, or Italian into their digit representation.
🌐
Kaggle
kaggle.com › general › 221399
Number names to digits (Python problem) | Kaggle
Is there an automatic way to convert number names (e.g., zero, one, two, …) stored as strings in a dataframe, to digits (i.e., 0, 1, 2, …) using Python? df.r...
🌐
PyPI
pypi.org › project › word2number
word2number · PyPI
This is a Python module to convert number words (eg. twenty one) to numeric digits (21). It works for positive numbers upto the range of 999,999,999,999 (i.e.
🌐
Reddit
reddit.com › r/learnpython › splitting a number into its component digits without quotations or commas
r/learnpython on Reddit: Splitting a number into its component digits without quotations or commas
March 29, 2024 -

Basically what the title says. I need to write a program that splits a given five digit number into the digits that make it up, in the order in which they appear. For example: 54321

5 4 3 2 1

I’ve tried a couple of different things and can’t seem to get it right.

My teacher suggested using // and % to do it but I don’t know how to apply that.

Thank you in advance.

Edit: I don’t know the etiquette for editing posts but I wanted to thank everyone that took the time to answer my question. I managed to come up with a solution thanks to all the tips and explanations. Thank you

🌐
YouTube
youtube.com › codesavant
Split an Integer Into a List of Digits in Python - YouTube
This tutorial shows you how to use the modulo operator and floor division to split an integer into a list of digits in Python 3. In this video, you learn to ...
Published: December 11, 2021
Views: 11K
Top answer
1 of 12
106

Convert the integer to string first, and then use map to apply int on it:

>>> num = 132
>>> map(int, str(num))    #note, This will return a map object in python 3.
[1, 3, 2]

or using a list comprehension:

>>> [int(x) for x in str(num)]
[1, 3, 2]
2 of 12
24

There are already great methods already mentioned on this page, however it does seem a little obscure as to which to use. So I have added some mesurements so you can more easily decide for yourself:


A large number has been used (for overhead) 1111111111111122222222222222222333333333333333333333

Using map(int, str(num)):

import timeit

def method():
    num = 1111111111111122222222222222222333333333333333333333
    return map(int, str(num))

print(timeit.timeit("method()", setup="from __main__ import method", number=10000)

Output: 0.018631496999999997

Using list comprehension:

import timeit

def method():
    num = 1111111111111122222222222222222333333333333333333333
    return [int(x) for x in str(num)]

print(timeit.timeit("method()", setup="from __main__ import method", number=10000))

Output: 0.28403817900000006

Code taken from this answer

The results show that the first method involving inbuilt methods is much faster than list comprehension.

The "mathematical way":

import timeit

def method():
    q = 1111111111111122222222222222222333333333333333333333
    ret = []
    while q != 0:
        q, r = divmod(q, 10) # Divide by 10, see the remainder
        ret.insert(0, r) # The remainder is the first to the right digit
    return ret

print(timeit.timeit("method()", setup="from __main__ import method", number=10000))

Output: 0.38133582499999996

Code taken from this answer

The list(str(123)) method (does not provide the right output):

import timeit

def method():
    return list(str(1111111111111122222222222222222333333333333333333333))
    
print(timeit.timeit("method()", setup="from __main__ import method", number=10000))

Output: 0.028560138000000013

Code taken from this answer

The answer by Duberly González Molinari:

import timeit

def method():
    n = 1111111111111122222222222222222333333333333333333333
    l = []
    while n != 0:
        l = [n % 10] + l
        n = n // 10
    return l

print(timeit.timeit("method()", setup="from __main__ import method", number=10000))

Output: 0.37039988200000007

Code taken from this answer

Remarks:

In all cases the map(int, str(num)) is the fastest method (and is therefore probably the best method to use). List comprehension is the second fastest (but the method using map(int, str(num)) is probably the most desirable of the two.

Those that reinvent the wheel are interesting but are probably not so desirable in real use.