[Tutor] checking substrings in strings

Alan G alan.gauld at freenet.co.uk
Thu Aug 25 10:27:34 CEST 2005


> 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. I have now resorted to
> 

Which version of Python?

>>> 'boo' in 'mybigbooboo'
True
>>>

Works for me in Python 2.4...

Alan G.
(Regular readers will note I now have 2.4 installed! :-)


More information about the Tutor mailing list