I am new to Python (2 weeks!) And struggling with the following:
I have a list of URLs that I want to iterate over and find only specific URLs. To do this I want to check that all members of the tuple are present in the URL.
I realized that I needed the any () operator, but I could not get the syntax correctly:
allurls = [<big list of URLs>] words = ('bob', 'fred', 'tom') urlsIwant = [x for x in allurls if any(w for w in words) in x]
gets me
TypeError: 'in <string>' requires string as left operand, not bool
I do not think this is relevant, but my actual code
urlsIwant = sorted(set([x for x in allurls if dict['value'] in x and any(w for w in words) in x]))
source share