[Tutor] how to do multiple searching against many lists
Pujo Aji
ajikoe at gmail.com
Thu Jan 19 19:14:30 CET 2006
Yes you can.
you can make:
search_list =['cat','python','parrot','donkey','e.coli']
animals = ['python','cat','tiger','donkey','zebra','lemur']
birds = ['parrot','mina','oriole','blue jay']
bacteria = ['e.coli','bacillus','staphy','acetobacter']
mydic = {}
for animal in animals :
mydic[animal] = 'animal'
for bird in birds:
mydic[bird] = 'bird'
for bacteri in bacteria:
mydic[bacteri] = 'bacteria'
for x in search_list:
print x, mydic[x]
Don't forget to include 'python' in animals group.
Cheers,
pujo
On 1/19/06, Srinivas Iyyer <srini_iyyer_bio at yahoo.com> wrote:
>
> Hi Group,
>
> my Problem:
>
> I have soms list for variety of animals, birds,
> bacteria
>
>
> I have another list:
> search_list =
> ['cat','python','parrot','donkey','e.coli']
>
> animals = ['cat','tiger','donkey','zebra','lemur']
> birs = ['parrot','mina','oriole','blue jay']
> bacteria =
> ['e.coli','bacillus','staphy','acetobacter']
>
> my output should look like this:
>
> cat '\t' animal
> python '\t' animal
> parrot '\t' bird
> donkey '\t'animal
> e.coli '\t' bacteria
>
> Can I do this using dictionaries , so that to make it
> faster?
>
> Thanks
> Srini
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060119/f1140311/attachment.htm
More information about the Tutor
mailing list