# -*- coding: utf-8 -*-
"""LabTask2.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1_fAeXc453UUSqqcDN4U-DllxwZrkKNeT
"""

open = ["[","{","("]
close = ["]","}",")"]
def function(myStr):
    stack = []
    for i in myStr:
        if i in open:
            stack.append(i)
        elif i in close:
            pos = close.index(i)
            if ((len(stack) > 0) and (open[pos] == stack[len(stack)-1])):
                stack.pop()
            else:
                return "Unbalanced"
    if len(stack) == 0:
        return "Balanced"
    else:
        return "Unbalanced"

x=input("Enter equation: ")
equation = x
print("The eq '", x,"' is ", function(equation))


77c0dbc6902c082d374652564a8a13843ea6ca50
<mask token>

<mask token>


def function(myStr):
    stack = []
    for i in myStr:
        if i in open:
            stack.append(i)
        elif i in close:
            pos = close.index(i)
            if len(stack) > 0 and open[pos] == stack[len(stack) - 1]:
                stack.pop()
            else:
                return 'Unbalanced'
    if len(stack) == 0:
        return 'Balanced'
    else:
        return 'Unbalanced'


<mask token>

<mask token>


def function(myStr):
    stack = []
    for i in myStr:
        if i in open:
            stack.append(i)
        elif i in close:
            pos = close.index(i)
            if len(stack) > 0 and open[pos] == stack[len(stack) - 1]:
                stack.pop()
            else:
                return 'Unbalanced'
    if len(stack) == 0:
        return 'Balanced'
    else:
        return 'Unbalanced'


<mask token>
print("The eq '", x, "' is ", function(equation))

<mask token>
open = ['[', '{', '(']
close = [']', '}', ')']


def function(myStr):
    stack = []
    for i in myStr:
        if i in open:
            stack.append(i)
        elif i in close:
            pos = close.index(i)
            if len(stack) > 0 and open[pos] == stack[len(stack) - 1]:
                stack.pop()
            else:
                return 'Unbalanced'
    if len(stack) == 0:
        return 'Balanced'
    else:
        return 'Unbalanced'


x = input('Enter equation: ')
equation = x
print("The eq '", x, "' is ", function(equation))

# -*- coding: utf-8 -*-
"""LabTask2.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1_fAeXc453UUSqqcDN4U-DllxwZrkKNeT
"""

open = ["[","{","("]
close = ["]","}",")"]
def function(myStr):
    stack = []
    for i in myStr:
        if i in open:
            stack.append(i)
        elif i in close:
            pos = close.index(i)
            if ((len(stack) > 0) and (open[pos] == stack[len(stack)-1])):
                stack.pop()
            else:
                return "Unbalanced"
    if len(stack) == 0:
        return "Balanced"
    else:
        return "Unbalanced"

x=input("Enter equation: ")
equation = x
print("The eq '", x,"' is ", function(equation))

