Split a List having Single Integer - Python Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report We are given a list containing a single integer, and our task is to split it into separate digits while keeping the list structure intact. For example, if the input is a = [12345], the output should be [1, 2, 3, 4, 5]. Let's discuss different methods to do this in Python.Using List Comprehension We can convert the integer to a string, iterate through its characters and convert them back to integers. Python # Initializing list a = [12345] # Splitting the integer into digits result = [int(digit) for digit in str(a[0])] print(result) Output[1, 2, 3, 4, 5] Explanation:str(a[0]) converts the integer to a string "12345".The list comprehension iterates through each character, converting it back to an integer.Let's explore some more ways and see how we can split a list having single integer in Python.Table of ContentUsing map() Using a Loop and Integer DivisionUsing divmod() for Better Integer DivisionUsing map() map() function can apply int() to each character of the string representation of the number. Python # Initializing list a = [12345] # Splitting the integer using map() result = list(map(int, str(a[0]))) print(result) Output[1, 2, 3, 4, 5] Explanation:str(a[0]) converts the integer to a string.map(int, str(a[0])) applies int() to each digit.list() converts the result back to a list.Using for Loop and Integer DivisionWe can extract digits manually by repeatedly dividing the number by 10. Python # Initializing list a = [12345] # Extracting digits using integer division num = a[0] result = [] while num > 0: result.append(num % 10) # Extract last digit num //= 10 # Remove last digit result.reverse() # Reverse to maintain correct order print(result) Output[1, 2, 3, 4, 5] Explanation:The loop extracts digits from right to left using num % 10.num //= 10 removes the last digit after extracting it.Since digits are added in reverse order, result.reverse() ensures the correct order.This method does not use string conversion but is slightly slower than string-based methods.Using divmod() for Better Integer Divisiondivmod() function simplifies integer division and remainder extraction. Python # Initializing list a = [12345] # Extracting digits using divmod() num = a[0] result = [] while num > 0: num, digit = divmod(num, 10) # Get quotient and last digit result.append(digit) result.reverse() print(result) Output[1, 2, 3, 4, 5] Explanation:divmod(num, 10) returns both the quotient and last digit in one step.This avoids separate division and modulo operations, making the method more efficient than a standard loop. Comment More infoAdvertise with us Next Article Python - Integers String to Integer List E everythingispossible Follow Improve Article Tags : Python Python Programs Python list-programs Practice Tags : python Similar Reads Python - Integers String to Integer List In this article, we will check How we can Convert an Integer String to an Integer List Using split() and map()Using split() and map() will allow us to split a string into individual elements and then apply a function to each element. Pythons = "1 2 3 4 5" # Convert the string to a list of integers u 2 min read List As Input in Python in Single Line Python provides several ways to take a list as input in Python in a single line. Taking user input is a common task in Python programming, and when it comes to handling lists, there are several efficient ways to accomplish this in just a single line of code. In this article, we will explore four com 3 min read Python - Binary list to integer A binary list represents binary digits (0s and 1s) as individual elements of a list. This article will explore various methods to convert a binary list into an integer.Using int() with String ConversionThis is the most efficient method. By joining the binary list into a string and using the built-in 3 min read Python | Split a list into sublists of given lengths The problem of splitting a list into sublists is quite generic but to split in sublist of given length is not so common. Given a list of lists and list of length, the task is to split the list into sublists of given length. Example: Input : Input = [1, 2, 3, 4, 5, 6, 7] length_to_split = [2, 1, 3, 1 2 min read How to Split Lists in Python? Lists in Python are a powerful and versatile data structure. In many situations, we might need to split a list into smaller sublists for various operations such as processing data in chunks, grouping items or creating multiple lists from a single source. Let's explore different methods to split list 3 min read Split a Python List into Sub-Lists Based on Index Ranges The task of splitting a Python list into sub-lists based on index ranges involves iterating through a list of index pairs and extracting the corresponding slices. Given a list a and a list of tuples b, where each tuple represents a start and end index, the goal is to create sub-lists that include el 3 min read Like