[Tutor] How to determine if every character in one string is inanother string?

Alan Gauld alan.gauld at btinternet.com
Thu Jul 26 01:01:34 CEST 2007


"Terry Carroll" <carroll at tjc.com> wrote

>   if Y in X:
>
> Which is much more elegant/pythonic; but I didn't know you could do 
> that
> with one string over another.  For some reason, I had thought Y 
> would have
> to exactly match one iterable element in X (e.g., one element of a 
> list,
> or one character of a string) for that to work.

FWIW I believe that 'in' did only work for single characters up until
version 2.X so your ideas may have been based on experiences with
an earlier Python version.

Alan G. 




More information about the Tutor mailing list