题解 | #字符统计#用sorted套娃

字符统计

http://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0

while True:
    
    try:
        str_input = input()
        new_list = list(set(str_input))
        str_dict = {}
        for c in new_list:
            str_dict[c] = str_input.count(c)
        res_list = sorted(sorted(str_dict.items(), key=lambda x : x[0]), key=lambda y: y[1], reverse=True)
        result = ''
        for i in res_list:
            result += i[0]
        print(result)
        
        
    except:
        break
全部评论
for i in res_list: result += i[0] 请问大佬,这个 i 是元组吗?为什么 res_list 从 sorted 套娃语句接受的是元组类型的数据?
点赞 回复 分享
发布于 2024-03-05 22:48 广东
学到了,多谢大佬
点赞 回复 分享
发布于 2022-11-06 17:31 陕西

相关推荐

05-16 11:16
已编辑
东华理工大学 Java
牛客73769814...:盲猜几十人小公司,庙小妖风大,咋不叫她去4️⃣呢😁
牛客创作赏金赛
点赞 评论 收藏
分享
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-03 16:22
点赞 评论 收藏
分享
评论
15
7
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务