List of strings

Paul Watson pwatson at redlinepy.com
Wed Aug 17 22:58:25 EDT 2005


Mohammed Altaj wrote:
> Hi All
> 
> Thanks for your reply , what i am doing is , i am reading from file ,
> using readlines() , I would like to check in these lines , if there is
> line belong to another one or not , if it is , then i would like to
> delete it
> 
> ['0132442\n', '13\n', '24\n'] 
> 
> '13' is already in '0132442'
> '24' is already in '0132442' 
> 
> Thanks 

$ python
Python 2.4.1 (#1, Jul 19 2005, 14:16:43)
[GCC 4.0.0 20050519 (Red Hat 4.0.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> line = '0132442\n'
 >>> line
'0132442\n'
 >>> line.find("13")
1
 >>> line.find("03")
-1
 >>> line.find("24")
3
 >>> print line.find.__doc__
S.find(sub [,start [,end]]) -> int

Return the lowest index in S where substring sub is found,
such that sub is contained within s[start,end].  Optional
arguments start and end are interpreted as in slice notation.

Return -1 on failure.



More information about the Python-list mailing list