I know about:
if 'a' in 'cat':
win()
but is there a better way to find if there are either two letters in a string?
Listed below are some ways
if 'a' in 'cat' or 'd' in 'cat':
win()
if re.search( '.*[ad].*', 'cat' ):
win()
but is there something cleaner / faster / sharper?
how
if either ['a', 'd'] in 'cat':
win()
source
share