List Comprehension With *args
I would like to write a function to return a set of strings using python´s list comprehension if any of the passed arguments is in the list. However, it throws requires string as
Solution 1:
You were almost there:
defcheckFor(*args):
return {a['title'] for a in soup.findAll('a') if'title'in a.attrs andany(arg in a['title'] for arg in args)}
You're just missing one more for
to expand the tuple args
into its elements.
Post a Comment for "List Comprehension With *args"