Can you make a variable , \(a\), in Python that can take as many pairs of brackets and returns the number of pairs of the brackets?

Example:

>>> a
0
>>> a()()
2
>>> a()()()()()() + 1
7