This is my function:
def sub(number):
tmp = []
tmp.append(number)
while len(str(number)) > 1:
tmp.append(int(str(number)[:-1]))
number = int(str(number)[:-1])
return tmp
Output:
Input: 1234
output: [1234, 123, 12, 1]
Now my question is, Is there any more efficient way to do this in the python?