def check_and_join(phrase, symbols=None, filter=None):
 rv = ''.join(''.join(phrase))
 if (symbols is not None):
  symbols = check_and_join(symbols)
  missing = ''.join(list(sorted((set(rv) - set(symbols)))))
  if missing:
   if (not filter):
    raise ValueError(('characters in phrase but not symbols: "%s"' % missing))
   rv = translate(rv, None, missing)
 return rv

def check_and_join ( phrase , symbols = None , filter = None ) : rv = '' . join ( '' . join ( phrase ) ) if ( symbols is not None ) : symbols = check_and_join ( symbols ) missing = '' . join ( list ( sorted ( ( set ( rv ) - set ( symbols ) ) ) ) ) if missing : if ( not filter ) : raise ValueError ( ( 'characters in phrase but not symbols: "%s"' % missing ) ) rv = translate ( rv , None , missing ) return rv
joins characters of phrase and if symbols is given .