List of digits from a number (python) ... Save Report LLDavid - Last answer on 9 déc. 2011 2 answers Hello, I work with Python I want to create a list of digits from a number example: 35482345965 should give l=[3,5,4,8,2,3,4,5,9,6,5] Could someone give me the code for that? Thanks a lot. Show more Related links: Convert a month from number to letter RESOLVED combination of sums equal to target value mirror value of a number python, square and cubic In a formula: "between" condition 2 values Python: condition between two values, in both directions quickly 2 answers Sorted by date Votes Date Descending date Answer 1 / 2 - Best answer The best answer is the one that has been validated by our teams. ... Report heyquem Hello, - with a list comprehension: x = 35482345965 print [int(c) for c in str(x)] - in a functional programming style: x = 35482345965 print map(int,str(x)) - to obtain the digits in a tuple, immutable = less memory usage: x = 35482345965 print tuple(int(c) for c in str(x)) Answer 2 / 2 ... Report LLDavid Author Thank you very much!!! Show full discussion
Answer 1 / 2 - Best answer The best answer is the one that has been validated by our teams. ... Report heyquem Hello, - with a list comprehension: x = 35482345965 print [int(c) for c in str(x)] - in a functional programming style: x = 35482345965 print map(int,str(x)) - to obtain the digits in a tuple, immutable = less memory usage: x = 35482345965 print tuple(int(c) for c in str(x))