469,343 Members | 5,380 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

List of strings

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

Aug 17 '05 #1
2 1158
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.
Aug 18 '05 #2
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
Aug 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Gordon Airport | last post: by
21 posts views Thread by Timothy Babytch | last post: by
7 posts views Thread by David. E. Goble | last post: by
5 posts views Thread by Someone | last post: by
27 posts views Thread by Tripper | last post: by
8 posts views Thread by dmp | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.