[Tutor] checking substrings in strings

John Fouhy john at fouhy.net
Thu Aug 25 10:28:39 CEST 2005

On 8/25/05, Frank Hoffsümmer <frank.hoffsummer at gmx.de> wrote:
> Hello,
> I would like to check if a certain word exists in a given string.
> since I learned to love lists, I used
> if myword in mystring:
> ...didnt work.

What version of python are you using? This was introduced in Python 2.3.

ActivePython 2.4.1 Build 245 (ActiveState Corp.) based on
Python 2.4.1 (#65, Mar 30 2005, 09:33:37) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 'bar' in 'foobarbaz'


More information about the Tutor mailing list