你题目没照全,ls列表是要排序输出吧,【5】处应该是对列表排序操作
s="abcdgdedcffahh" ls=[] for c in s: if s.count(c)==1: ls.append(c) print("只出现一次的字符有{}个".format(len(ls))) ls.sort() print(ls)
如果对你有帮助,可以给我个采纳吗,谢谢!! 点击我这个回答右上方的【采纳】按钮