题解 | #统计人次#

统计人次

https://www.nowcoder.com/practice/325adc585eeb4791a5d92389e5b6c6cc

def main():
    s1 = input()
    try:
        lists = s1.split(' ')
        lists = filter(lambda x: x, lists) #过滤掉空字符
        
        total = 0
        first = -1 #设为-1,避免first==-1判断失效
        i = 0
        for item in lists:
            if item == 'NiuNiu':
                total += 1

                if first == -1:
                    first = i
            
            i += 1

        print(total)
        print(first)
    except Exception as e:
        print(str(e))


if __name__ == '__main__':
    main()

全部评论

相关推荐

06-25 09:33
厦门大学 Java
程序员饺子:现在日常估计没啥hc了,等到八月多估计就慢慢有了。双九✌🏻不用焦虑的
投递快手等公司7个岗位
点赞 评论 收藏
分享
07-11 11:15
中南大学 Java
好可爱的hr姐姐哈哈哈哈
黑皮白袜臭脚体育生:兄弟们貂蝉在一起,吕布开了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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