例1
收入123
输出321
例2
输入-123
输出-321
例3
输入120
输出21
答案
思路,
1、先考虑末尾是0的情况时,翻转后需要把0去掉,
2、当有-号时,把翻转后末尾的-号去掉,再在前面加一个-号
3、正数时不变

a= -56435tmp = str(a)[::-1] print(tmp[0]) while True:if tmp[0] == '0':tmp = tmp[1::]continueelse:break if str(a)[0] == '-':c = '-'+ tmpb = c[:-1]print(b) else:b= tmpprint(b)
上一篇:html5+css3
下一篇:ROS1 LTS版本安装教程