```
num = int(input("Enter a number: "))

while num > 0:
    num2 = num
    dig = 0

    while num2 > 0:
        num2 = num2 //10
        dig = dig + 1

    x = num // 10**(dig-1)
    if dig == 1:
        print (x, end = " ")
    else:
        print (x, end = ", ")
    num = num % 10**(dig-1)

```

I wrote this code which outputs the number from left to right unless there is a zero at the middle or at the last of the number

For example:
If `input = 12345`; `output = 1, 2, 3, 4, 5`

However, if `input = 120` OR `102`; `output = 1, 2,` OR `1, 2`

Is there any workaround for this? I have been told not to use string indexing or lists to solve this.