The title

If A person mentions pintia many times in A paragraph, the spelling A is true love. Check how many pintia appear in A given text.

Input format: Input gives a non-empty string with a total length of up to 10 4 characters in a line, consisting of English letters and punctuation marks, and. And Spaces, ending with a carriage return.

Output format: First print how many times pintia or pintia appear in a given text in the first line.

If not once, print Wu Gan on the second line; If there are but no more than 3 times, output “You ai”. If more than 3 times, output Zhen ai LA (True love).

Note that pintia is only counted once when it appears as a full and separate word, that is, it must be separated from other words by Spaces or punctuation.

Example 1:0 Wu gan Example 2: This is a pintiatest. This is apintia test. Hey I love pintia A no blank line Output Example 2:1 You AI No blank line input Example 3:  This is apintiatest. Hey I love pintia, really zhen ai pintia la,pintia is my favorite place to go. Come on visit Pintia. No blank line at the end Example 3:4 Zhen AI LA No blank line at the endCopy the code

Their thinking

inputStr = input()
# inputStr = "This is apintiatest. Hey I love pintia, really zhen ai pintia la,pintia is my favorite place to go. Come on visit Pintia."
# inputStr = "This is apintia test. Hey I love pintia a"
# inputStr = ".pintia."

length = len(inputStr)
res = 0
testStr1 = "pintia"
testStr2 = "Pintia"
for i in range(0, length-len(testStr1)+1):
    test = inputStr[i:i+len(testStr1)]
    if test== testStr1 or test== testStr2:
        leftStr = " " if i==0 else inputStr[i-1]
        # print(inputStr[i+len(testStr1)])
        rightStr = " " if i+len(testStr1) == length else inputStr[i+len(testStr1)]
        if leftStr.isalpha() == False and rightStr.isalpha() == False:
            res += 1
print(res)
if res == 0:
    print("wu gan")
elif res <= 3:
    print("you ai")
else:
    print("zhen ai la")
Copy the code