You can just cover it in brackets.

a = 1234
print([a])

Or append()

b = []
b.append(a)

output

[1234]
Answer from Thavas Antonio on Stack Overflow
Discussions

python - Converting integer to digit list - Stack Overflow
What is the quickest and cleanest way to convert an integer into a list? For example, change 132 into [1,3,2] and 23 into [2,3]. I have a variable which is an int, and I want to be able to compar... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Convert NumPy array to Python list - Stack Overflow
How do I convert a NumPy array into a Python List? More on stackoverflow.com
๐ŸŒ stackoverflow.com
Django rest framework how to serialize a list of strings?

You can't just pass a list of strings. JSON is basically like a python dictionary. You need to format your object as a dictionary e.g.

{"strings":[string1, string2, string3]}

Each string above is a string object.

It's better to pass each string though with a dictionary keyword so it's easier to extract later, or nested dictionaries if you need nester data storage.

Serialising converts python objects to JSON but it has to be something that has similar properties to JSON in terms of structure. Python has that in dictionaries, so we feed it dictionaries. Read up on JSON and how it looks. You'll recognize the similarities instantly.

More on reddit.com
๐ŸŒ r/Python
3
1
September 28, 2017
[Python] How do you increment/decrement values in a list?

x -= 1 conceptually means "create a new number object that has the value one less than x and make x refer to that object." This does not affect the list at all, because the list is still referring to the old object.

Use a list comprehension or iterate by index. See this thread from just the other day.

More on reddit.com
๐ŸŒ r/learnprogramming
4
5
October 30, 2012
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ how to convert an integer to a list in python
How to Convert an Integer to a List in Python - Be on the Right Side of Change
August 22, 2022 - The results are output to the terminal as a List of Integers. This example uses List and the map() function to convert an Integer to a String, extract each element and convert it to a List of Integers.
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.

๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ convert-lists-to-arrays-and-back-in-python
How to Convert a List to an Array and Back in Python
December 11, 2025 - Next, we create an array called my_array by calling the array() function and passing it two arguments: the type code 'i', which specifies that we want an array of signed integers, and my_list, which is the list we want to convert. When we print my_array, we should see the following output: ... This shows that my_array is now an array containing the same values as my_list. To convert an array back to a list, we can use Python's built-in list() function. Here's an example of how to convert an array to a list in Python:
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-convert-number-to-list-of-integers
Python - Convert Number to List of Integers - GeeksforGeeks
Combination of str() and map() is a straightforward and efficient way to convert a number into a list of integers.
Published: July 11, 2025
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-program-to-convert-list-of-integer-to-list-of-string
Python - Convert List of Integers to a List of Strings - GeeksforGeeks
July 12, 2025 - For example, if we have a list like [1, 2, 3] then the output should be ['1', '2', '3']. In Python, there are multiple ways to do this efficiently, some of them are: using functions like map(), reduce() or even list comprehensions.
Find elsewhere
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ convert-number-to-list-of-integers-in-python
Convert number to list of integers in Python
May 20, 2020 - negative_number = -1342 # Method 1: Using absolute value digits_list1 = [int(digit) for digit in str(abs(negative_number))] print("Using abs():", digits_list1) # Method 2: Remove minus sign first digits_list2 = [int(digit) for digit in ...
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ python-convert-numpy-array-to-list
Convert NumPy Array to List in Python Easily | DigitalOcean
April 19, 2025 - Learn how to convert a NumPy array to a Python list using simple methods with code examples. Ideal for beginners and data scientists working with NumPy.
๐ŸŒ
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
June 28, 2025 - Write a Python program to convert a given number (integer) to a list of digits. Use map() combined with int on the string representation of n and return a list from the result. ... # Define a function 'digitize' that takes an integer 'n' as ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-convert-array-ordinary-list-items
Python - Convert an array to an ordinary list with the same items - GeeksforGeeks
December 17, 2024 - If we are working with a NumPy array, we can use the tolist() method to convert it into a regular Python list. NumPy arrays are commonly used for numerical data and large datasets.
๐ŸŒ
DataCamp
datacamp.com โ€บ doc โ€บ numpy โ€บ array-to-list
NumPy Array to List
NumPy provides functionalities for data input/output and conversion, allowing transitions between different data formats. A common operation is converting a NumPy array to a Python list, which can be useful for interoperability with other Python data structures.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-create-list-of-numbers-with-given-range
Create List of Numbers with Given Range - Python - GeeksforGeeks
Explanation: np.arange(r1, r2).tolist() uses NumPy's arange() function to generate a sequence of numbers from r1 o r2 .tolist() method converts the NumPy array into a Python list.
Published: July 11, 2025
๐ŸŒ
Quora
quora.com โ€บ How-do-I-convert-an-7-digit-integer-to-a-list-in-Python
How to convert an 7-digit integer to a list in Python - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ array
Python Array of Numeric Values
March 26, 2024 - To create an array of numeric values, we need to import the array module. For example: import array as arr a = arr.array('d', [1.1, 3.5, 4.5]) print(a) ... Here, we created an array of float type. The letter d is a type code.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ conversion-of-integer-string-to-list-in-python
Conversion of Integer String to list in Python
March 27, 2026 - int_str = "14 -15 17 18" result = [] i = 0 while i < len(int_str): if int_str[i].isdigit() or int_str[i] == '-': num = "" while i < len(int_str) and (int_str[i].isdigit() or int_str[i] == '-'): num += int_str[i] i += 1 if num and num != '-': ...
๐ŸŒ
Ducmanhphan
ducmanhphan.github.io โ€บ 2022-04-17-how-to-convert-int-to-list-integer
How to convert int[] to List of Integer
Below is the solution that we use stream() method of Arrays class. int[] rawData = {1, 3, 5}; List<Integer> data = Arrays.stream(rawData) // IntStream .boxed() // Stream<Integer> .collect(Collectors.toList());
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ python-how-to-generate-a-list-of-integers-between-two-values-in-python-395064
How to generate a list of integers between two values in Python | LabEx
If you're working with the NumPy library, you can use the numpy.arange() function to generate a list of integers. NumPy is a powerful library for scientific computing in Python, and it provides efficient ways to work with arrays and matrices. Here's an example:
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-convert-list-to-python-array
Convert list to Python array - Python - GeeksforGeeks
July 12, 2025 - Another option is to use the numpy.array() method, which provides more features for working with arrays ยท This task can be easily performed using the array() function. This is an inbuilt function in Python to convert to an array.