在用Python写PTA的时候,出现“非零返回”的问题是什么意思?最后明明是有输出的啊
n =eval(input())
for i in range(n):
str = input()
strList = list(str)
list1 = []
last = ''
for x in strList:
if x == '{' or x=='(' or x == '[':
list1.append(x)
elif x == '}':
if last == '{':
a = list1.pop()
elif x == ')':
if last == '(':
a = list1.pop()
elif x==']':
if last == '[':
a = list1.pop()
if len(list1):
last = list1[-1] #last永远是字符串最后一个字符
if len(list1):
print('No')
else:
print('Yes')
这个是代码,问题就是匹配三种扩号的字符串,输出Yes或No