search for pattern in StringList

Daniel Daniel.Kinnaer at AdValvas.be
Mon Dec 18 15:06:33 CET 2000


As a Python newbie, I was trying a very simple exercise, but got
stuck. Is there someone who can help me complete this code, please?

Thanks.
Daniel


MyList = ['an','been','call','door']

print "Scanning a StringList"

for i in range(0, len(MyList)):
    print i, MyList[i]

#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 : ???





More information about the Python-list mailing list