(python)为啥只有60分。。。
查看原帖
(python)为啥只有60分。。。
462513
Jiwj123楼主2021/6/11 16:00
str1 = input().lower()
sentence = input().lower()
cnt = 0
for i in sentence.split():
    if i == str1:
        cnt += 1
if cnt != 0:
    print(cnt, end=" ")
    for i in range(len(sentence)):
        for j in range(len(str1)):
            if sentence[i+j] != str1[j]:
                break
        if j == len(str1)-1 and sentence[i] == str1[0] and sentence[i+j+1] == " " and (i == 0 or sentence[i-1] == " "):
            print(i)
            break
else:
    print(-1)

2021/6/11 16:00
加载中...