a = input()
mas = []
answer = ""
test01 = "Incorrect"
test02 = "Incorrect"
def check():
global mas
global answer
global test01
global test02
#Bad, but this test01 deleted
#Second step for check
for infinity in range(100):
for i in range(len(mas)):
try:
m = i + 1
if mas[i] == "[" and mas[m] == "]" or mas[i] == "{" and mas[m] == "}" or mas[i] == "(" and mas[m] == ")":
del mas[i]
del mas[i]
except:
pass
if len(mas) == 0:
test02 = "Correct"
break
else:
test02 = "Incorrect"
#End testing
if test02 == "Correct":
answer = "correct"
else:
answer = "incorrect"
for i in range(len(a)):
if a[i] == "{":
mas.append(a[i])
if a[i] == "[":
mas.append(a[i])
if a[i] == "(":
mas.append(a[i])
if a[i] == "}":
mas.append(a[i])
if a[i] == "]":
mas.append(a[i])
if a[i] == ")":
mas.append(a[i])
del a
del i
check()
print(answer)
Объяснение:
Благодарности не требую, все ради Вас отметить как лучшее решение
10/10
a = input()
firs = 0
sec = 0
third = 0
for i in a:
if(i == '{' or i == '}'):
firs += 1
elif (i == '(' or i == ')') :
sec += 1
elif(i == '[' or i == ']'):
third += 1
if( (firs+sec+third) % 2 == 0 ):
print('correct')
else:
print('incorrect')
Объяснение:
из 10