题解 | #统计人次#
统计人次
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()