• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
September 04, 2022 |1.4K Views

Python program to convert number to List of Integers

Description
Discussion

In this video, we'll write a program on how to convert a number to a list of integers.

We have covered the following approaches in this video:
1. Using list comprehension
2. Using the map
 

Method 1: Using List comprehension: We convert an integer into a string and again split the string into 
separate characters, convert them into integers using the Python int() function and store them inside a list comprehension.

Method 2: Using the map() function: We pass the int method in the first parameter of the map() function and the string representation of the number in the 2nd parameter. Then we convert the return value from the map() function to a list using list().
The resulting list will contain the list of integers generated from the original integer value.

Python | Convert number to list of integers:
https://www.geeksforgeeks.org/python-convert-number-to-list-of-integers/