whilenum>0:digit=num%10num=num//10ifnum>1:print(digit,end="""+""")else:print(digit,end="")digit_sum+=digitprint("=",digit_sum,end="")print("")whiledigit_sum>10:digit=digit_sum%10digit_sum=digit_sum//10ifdigit_sum>1:print(digit,end="""+""")else:print(digit,end="")digit_sum+=digitprint("=",digit_sum,end="")print("")我是这样做的,但是第二个循环出了问题,最后的运算结果不对。但是一修改就很容易出现无限循环的情况
|