[Tutor] Re: joker signs?
Lee Harr
missive@hotmail.com
Sat Jan 4 21:16:03 2003
>x = ['ben','sandy','roger','hillary','john','betty']
>a = x.index('ben')
>print a
>---------
>0
>How to get indexes of all names which begin with "b" (like
> >x.index('b*')
>or, find all names that contain "er". Is it possible to do using some
> >joker
>letters like in os prompt?
How about a list comprehension?
x = ['ben','sandy','roger','hillary','john','betty']
[name for name in x if name.find('b') == 0]
[name for name in x if name.find('er') >= 0]
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963