Computer Science, asked by vcharithacherry, 9 months ago

Write a function matched(s) that takes as input a string s and checks if the brackets "(" and ")" in s are matched: that is, every "(" has a matching ")" after it and every ")" has a matching "(" before it. Your function should ignore all other symbols that appear in s. Your function should return True if s has matched brackets and False if it does not.

Answers

Answered by indiansmathsworld
2

Answer:

Such a lengthy question

Answered by Anonymous
2

def bracket_matcher(s):

    return s.count('(') == s.count(')')

Done in 2 lines.

Similar questions