Find the index of the first element from a set

Hello,

I am able to find the first instance of a character in a string:

s = 'abc]xy}[)'
s.index(']')
3

How may I find the first characters from the set { ‘)’ , ‘]’, ‘}’ }? To elaborate a little more, I search from the beginning of the string, and I encounter any of the three element ‘)’, ‘]’, ‘}’ and then I stop.

Thank you.

J

The ‘algorithm’ in natural language could be: ‘start from beginning of text and check every character whether it’s in set, if so return index of character and stop’. Expressed in Python:

s = 'abc]xy}[)'
stop =  { ')' , ']', '}' }

for i, char in enumerate(s):
    if char in stop:
        print(i)
        break