题解 | #字符个数统计#

字符个数统计

https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50

#输入一个字符串,用for循环遍历,不在就添加到集合中,在就跳过,输出所有结果,计数
strinput=input()
tar_list=[]
for i in strinput:
    if i not in tar_list:
        tar_list.append(i)  #第一个for循环,把每一种字符都append到集合中
    else:
        pass
count=0
for n in tar_list:  #第二个for循环,是计数,存在就加1
    if n in tar_list:
        count += 1
    else:
        break
print(count)
#职场打工人实录#
全部评论

相关推荐

评论
4
2
分享

创作者周榜

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