Python经典编程习题100例:第29例:判断数字位数

简介: Python经典编程习题100例:第29例:判断数字位数

题目描述:

给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。

解题思路:

> 就是切片,真爽

代码:

num=input()
print(len(num))
for i in range(len(num)):
    print(num[-1],end='')
    num=num[0:len(num)-1]


目录
相关文章
|
1天前
|
网络协议 Unix Python
Python编程-----网络通信
Python编程-----网络通信
8 1
|
2天前
|
存储 Python
【python】习题第10周题解
【python】习题第10周题解
10 1
|
2天前
|
Python
【python】习题 第10周
【python】习题 第10周
13 0
|
2天前
|
Python
【python】习题第9周
【python】习题第9周
14 0
|
2天前
|
数据安全/隐私保护 Python
【python】习题第8周
【python】习题第8周
10 0
|
2天前
|
Python
【python】习题第7周(下)
【python】习题第7周(下)
11 0
|
2天前
|
自然语言处理 Python
【python】习题第7周(上)
【python】习题第7周(上)
12 1
|
2天前
|
Python
【python】习题 6-10周(下)
【python】习题 6-10周(下)
10 0
|
2天前
|
自然语言处理 数据安全/隐私保护 Python
【python】习题 6-10周(中)
【python】习题 6-10周(中)
18 0
|
2天前
|
Python
【python】习题 6-10周(上)
【python】习题 6-10周(上)
9 0