List of strings
Tomi Kyöstilä
tomi.kyostila at gmail.com
Thu Aug 18 08:29:14 EDT 2005
Paul Watson wrote:
> 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.
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> line = '0132442\n'
>>> line
'0132442\n'
>>> "13" in line
True
>>> "03" in line
False
>>> "24" in line
True
--
dOb
More information about the Python-list
mailing list