return s与while要在同一层你的代码return s在while里面,循环一次就函数结束了啊另外你的while True也有问题,应该是 while n>0:,否则你这会成为死循环
def fun(a,n): s = 0 while n>0: s = a*n+s a = a*10 n = n-1 return s