Aug-14-2019, 02:43 AM
Quote:Last question, do you know if I could create a list of keywords, and if the keywords are there then is a Category x? So instead of if "/string1", there I can apply a list of keywords....or would be wrong?Absolutely. You can do something like this:
if any(item in Source for item in ['/string1', '/abc']): return 'Category 1'This combines the function any() which returns True if any items passed to it is True. I passed to it a list comprehension that loops through all items in a list and indicates whether they are contained in Source.