Question: python Write a function matcher in python that takes a string containing braces ([{()}]) as a parameter and returns True if the braces are matched,

python

Write a function matcher in python that takes a string containing braces ([{()}]) as a parameter and returns True if the braces are matched, and False otherwise. The braces may be nested. Your solution should not use any built-in or library functions other than those in the Stack and Queue classes provided.python Write a function matcher in python that takes a string containingbraces ([{()}]) as a parameter and returns True if the braces are

fix matching.py to pass matching_test.py

LI 00 9 matching.py 1 MODIFY ME TO IMPLEMENT YOUR SOLUTION 2 # TO PROBLEM 2: BRACE MATCHER 3 # 4 # NAME: FIXME 5 # ASSIGNMENT: Technical HW: Stacks & Queues 6 7 from Stack import Stack 8 9 # Returns True if the braces match, 10 # & False otherwise 11 def matcher(str): 12 Sri Stack() 13 return True 14 15 def main(): 16 print("matcher: ", matcher("[0]")) 17 18 # Don't run main on import 19 if __name_ main__": 20 main() 21 22 E 6 111 matching_test.py 1 # TEST FILE FOR MATCHER 2 # DO NOT MODIFY 3 from matching import matcher 4 5 E def test_matcher_pass_solo1(): 6 assert matcher("[ ]") == True 7 8 def test_matcher_pass_solo2(): 9 assert matcher("{ }") == True 10 11 def test_matcher_pass_none(): 12 assert matcher("hello") == True 13 14 E def test_matcher_pass_arith(): 15 | assert matcher("(45 + 36) - 5") == True 16 17 def test_matcher_pass_mix2(): 18 assert matcher("[0]") == True 19 20 Edef test_matcher_pass_mix3(): 21 lassert matcher("{[()]}") == True 22 23 E def test_matcher_pass_mix5(): | assert matcher("{ () [ [] ({}) } }") == True 25 26 def test_matcher_pass_mix_lots(): assert matcher("{[0]} [ ] ( ) ([{}]) { () [ [] ( {} ) ] } ( {[O] [] } {} )") == True 2 4 27

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!