lundi 24 décembre 2018

move to next item in list1 when when item from list2 is found, when both lists are compared

Sorry for complicated title, perhaps example'd be easier.

So I have two lists:

list1 = ['cat', 'dog', 'donkey']
list2 = ['http://cat1.com', 'http://cat2.com', 'http://dog1.com', http://dog2.com']

All I want is script, that "greps" list2 with list1 items but when it finds one ocurence, it moves to another item in list1, so it finds phrase "cat" in "http://cat1.com", then it checks list[1] item: 'dog'. When it's finish it should print all it's findings. I tried using .find() but it's not designed for list types of files.

Aucun commentaire:

Enregistrer un commentaire