How to represent digits of numbers in form of elements of list in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to represent digits of numbers in form of elements of list in python?

9th Jun 2020, 8:40 AM
Akarsh Srivastava
Akarsh Srivastava - avatar
4 Answers
+ 6
It would be great, if i could make us a sample how the list should look like, and what you expect as output. Thanks!
9th Jun 2020, 9:20 AM
Lothar
Lothar - avatar
+ 5
digits = [digit for digit in str(number)]
9th Jun 2020, 8:48 AM
HonFu
HonFu - avatar
+ 4
>>> n=127266373 >>> [int(d) for d in str(n)] [1, 2, 7, 2, 6, 6, 3, 7, 3] >>>
9th Jun 2020, 8:52 AM
Vijay Raj Jain
+ 2
Thanks everyone I got it...
9th Jun 2020, 10:11 AM
Akarsh Srivastava
Akarsh Srivastava - avatar