search for pattern in StringList

Simon Brunning SBrunning at trisystems.co.uk
Mon Dec 18 09:12:41 EST 2000


> From:	Daniel.Kinnaer at AdValvas.be [SMTP:Daniel.Kinnaer at AdValvas.be]
> Sent:	Monday, December 18, 2000 2:07 PM
> To:	python-list at python.org
> Subject:	search for pattern in StringList
> #try to show every item in MyList which contains an 'a'
> #that is 'an' and 'call'.   In Pascal :
> #for i:=0 to MyList.Items.Count -1 do
> #    if pos('a',MyList.Items[i])>0 then writeln(MyList.Items[i]) 
> #in Python : ???
 
myList = ['an', 'been', 'call', 'door']
for i in range(0, len(myList)):
    if myList[1].find('a') <> -1:
        print i, myList[i]





-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.




More information about the Python-list mailing list