Exceptions within sets in Python regular expressions

You already know that special characters inside [] become regular characters. There are, however, exceptions: if you want square brackets as characters inside [ ] - you need to escape them with a backslash. For example, in the following code, the search pattern looks like this: there is a square bracket between the x's:

pythontxt = 'x]x xax x[x x1x'
res = re.sub('x[\[\]]x', '!', txt)

print(res)

As a result, the following will be written to the variable:

python'! xax ! x1x'
Задание 1

Given a string:

pythontxt = 'x[]z x[[]]z x()z'

Write a regular expression that will find all words with the pattern: letter 'x', then square brackets any number of times, then letter 'z'.

Задание 2

Given a string:

pythontxt = 'x[]z x{}z x.z x()z x([])z'

Write a regular expression that will find all words with the pattern: letter 'x', then any number of any brackets, then letter 'z'.