字符串的降序
输入:数字或字符串
输出:降序后的数字
How to convert and sort?
step1: str()
step2:sorted()
step3:''.join()
step4: int()
def descending_order(num):
return int(''.join(sorted(str(num),reverse=True)))
num = 123456789
#num = '123456789'
print(descending_order(num))
num = ['9', '8', '7', '6', '5', '4', '3', '2', '1']
print(max(num),min(num))
网友评论