Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
350 B
1
Indexable
Never
stack=[]
st = "(([]))"
for item in st:
    if item=="(" or item=="[":
        print(1)
        stack.append(item)
    elif item=="]" and stack[-1]== "[":
        print(2)
        stack.pop(-1)
    elif item==")" and stack[-1]=="(":
        print(3)
        stack.pop(-1)
    else: 
        print("bad input")
        break
print(stack)