x = input('Input a number:')
a = x//10000
b = x % 10000//1000
c = x %1000//100
d = x%100//10
e = x%10
if a!= 0:
print('五位数:' + str(e) + str(d) + str(c) + str(b) + str(a))
elif b!= 0:
print('四位数:' + str(e) + str(d) + str(c) + str(b))
elif c!= 0:
print('三位数:' + str(e) + str(d) + str(c))
elif d!= 0:
print('二位数:' + str(e) + str(d))
else:
print('个位数:' + str(e))
python给一个不多于 5 位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字
最新推荐文章于 2024-06-20 17:44:19 发布