My integer input is suppose 12345
, I want to split and put it into an array as 1, 2, 3, 4, 5
.
How will I be able to do it?
You can convert a number into String and then you can use toCharArray() or split() method to separate the number into digits.
>>> [int(i) for i in str(12345)] [1, 2, 3, 4, 5]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With