Clear Brackets

Published by RosaTabula in

Create a function brackets() that takes a string and checks that the brackets in the math expression are correct. The function should return True or False.

Examples

brackets("(a*(b-c)..... )") ➞ True

brackets(")(a-b-45/7*(a-34))") ➞ False

brackets("sin(90...)+.............cos1)") ➞ False

Notes

  • The string may not contain brackets, then return True.
  • String may contain spaces.
  • The string may be empty.
Watch a quick demo on how Edabit works.