Python中这个程序用循环应该要怎么做才好

img

n=int(input('input a number(0-100000000): '))
while n>0:
    print(n % 10,end=' ')
    n = n//10
print('')
def func(n):
  l = list(str(n)) # 把数字拆分成列表
  l = list(reversed(l)) # 列表反转
  
  for i in l:
    print(i, end=' ')
  
  '''或者不用循环:
  print(' '.join(l))
  '''