鱼C论坛

 找回密码
 立即注册
查看: 8858|回复: 29

[技术交流] Python:每日一题 121

[复制链接]
发表于 2018-5-14 14:50:28 | 显示全部楼层
def switch(n):
    temp = 0
    for each in str(n):
        temp += int(each)
    if temp < 10:
        return temp
    else:
        return switch(temp)
   
   
def cus_sort(list_o):
    for i in range(len(list_o)-1):
        for j in range(len(list_o)-i-1):
            if list2.index(list_o[j]) > list2.index(list_o[j+1]):
                list_o[j], list_o[j+1] = list_o[j+1], list_o[j]
    return list_o


list3 = []
for each in list1:
    list3.append(switch(each))
print(cus_sort(list3))
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-9-26 02:40

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表