trying to match a string

Scott David Daniels Scott.Daniels at Acm.Org
Fri Jul 18 15:08:26 CEST 2008


arnimavidyarthy at gmail.com wrote:
> I am taking a string as an input from the user and it should only
> contain the chars:L , M or R
How about skipping re's and doing something like:
    set(input_string) <= set('LMR')
If you want to disallow the empty string:
    set([]) < set(input_string) <= set('LMR')

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list