splitting a number into digits python
>>> n = 43365644 >>> digits = [int(x) for x in str(n)] >>> digits [4, 3, 3, 6, 5, 6, 4, 4] >>> lst.extend(digits) # use the extends method if you want to add the list to another
Source: stackoverflow.com
split a number into its digits
function splitNum(num) { return String(num).split("").map(Number); } console.log(splitNum(1523)); // [1, 5, 2, 3] console.log(splitNum(2341)); // [2, 3, 4, 1] console.log(splitNum(325)); // [3, 2, 5] Run code snippetHide results
Source: stackoverflow.com