def isbalanced(s):
          c= 0
          for i in s:
              if i == b(b:
                  c += 1
              elif i == b)b:
                  c-= 1
              if c < 0:
                  return ans
          if c==0:
              return not ans
          return ans
      s=input(bEnter a string of brackets: b) 
      print(bGiven string is balanced :b,isbalanced(s))

      Python language logo
      Check the balance of parenthesis in Python


        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.