Well, first look at this one and:

1/ output seems never assigned as you remove the line
2/ for tuple use any():

    any(s in output for s in ('a','b'))

3/ ISO check at the end because it's an extension and it help for understanding.