I want to make a code that can match parenthesis. Assumptions are that parenthesis is given by string, and the input is given by list.
So below is my code: I got the error that:
'AttributeError: 'list' object has no attribute 'parenthesis''
Please let me know what's wrong with my code.
def push(item):  
    stack.append(item)
def peek():  
    if len(stack) != 0:
        return stack[-1]
def pop():  #delete step
    if len(stack) != 0:
        item = stack.pop(-1)
        return item
def check(item):
    global stack1
    stack1 =[]
    global stack2
    stack2 =[]
    if item == '{':
        stack1.push('1')
    elif item == '}':
        stack1.pop()
    elif item == '(':
        stack2.push('2')
    elif item == ')':
        stack2.pop()
def parenthesis(self):
    for i in len(self):
        tail = self.peek
        tail.check
        self.pop()
    if len(stack1) == 0 & len(stack2) ==0 :
        print('pass')
    else:
        print('fail')
stack = []
push('{')
push('}')
stack.parenthesis()
