PTA 乙级 1003 我要通过! (20分) Python

 

Python 

 1 num = eval(input())
 2 an = []
 3 for i in range(0,num):
 4     str = input()
 5     P = str.count('P')
 6     T = str.count('T')
 7     A = str.count('A')
 8     sum = P+T+A
 9     #print(sum)
10     #print(len(str))
11     if P!=1 or T!=1 or sum!=len(str) or A == 0:
12         an.append('NO')
13         continue
14     ap = str.find('P')
15     t = str.find('T')
16     pt = t - ap - 1
17     ta = len(str) - t - 1
18     if(ap*pt == ta and ap >= 0):
19         an.append('YES') 
20     else:
21         an.append('NO')
22 
23 for i in range(0,num):
24     print(an[i])

 

posted @ 2020-06-25 03:13  上帝的绵羊  阅读(271)  评论(0编辑  收藏  举报