Find a substring withing a string...

FooBar abc at attbi.com
Sat Jun 21 02:12:56 EDT 2003


In article <MPG.195db98e90b83bb49899fe at netnews.attbi.com>, abc at attbi.com 
says...
> 	OK I will be the first to admit that I am VERY new to Pythin and 
> know little of the syntax of this language.  I want to perform the 
> simple task of testing to see if a substring exists within string.  I 
> think the syntax is find(sting,substring) and the return is -1 if the 
> substirng is not found otherwise the start position of the substring in 
> the string.  is this correct?
> 
> 	Moreover is this code totally screwed?
> 
> 
> takeaction = find(stringvar,'LITERALSUB')
> if takeaction != -1:
>     action_to_take_if_found
> else:
>     action_tp_take_if_not_found
> 
> 
> 	Any help with this is appreciated as I am a total DFU when it 
> comes to this for now anyway...
> 
> 
> Thanks,
> DB
> 
> 
> 
> 
> 

Ah I just discovered that this box has an older Python on it.  I would 
need to know how to find if a substring exists in the string using 
version 1.5.2 of Python.  Help please!

DB


-- 

http://www.TheHappyCat.com
Please Help the Unwanted and Homeless Animals!







More information about the Python-list mailing list