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]
More Related Contents:
- Call int() function on every list element?
- How do I parse a string to a float or int?
- From list of integers, get number closest to a given value
- list to dictionary conversion with multiple values per key?
- converting a list of integers into range in python
- How to convert a string of space- and comma- separated numbers into a list of int? [duplicate]
- Splitting List That Contains Strings and Integers
- How to convert nested list of lists into a list of tuples in python 3.3?
- Converting a string that represents a list, into an actual list object
- Convert all strings in a list to integers
- How can I convert string values from a dictionary, into int/float datatypes?
- Convert a number to a list of integers [duplicate]
- How do I add together integers in a list (sum a list of numbers) in python?
- Getting the index of the returned max or min item using max()/min() on a list
- Why can tuples contain mutable items?
- Find and replace string values in list
- How to find most common elements of a list? [duplicate]
- How do you pick “x” number of unique numbers from a list in Python?
- How to convert list of key-value tuples into dictionary?
- Finding index of an item closest to the value in a list that’s not entirely sorted
- Python split string into multiple string [duplicate]
- How to convert a list to a list of tuples?
- How to input matrix (2D list) in Python?
- Combining Dictionaries Of Lists In Python
- How to get all combination of n binary value? [duplicate]
- Convert a columns of string to list in pandas
- Indexing a list with an unique index
- Why doesn’t assigning to the loop variable modify the original list? How can I assign back to the list in a loop? [duplicate]
- How to sort a 2D list? [closed]
- Python, Determine if a string should be converted into Int or Float