Mar-19-2019, 02:34 PM
def check(msg, strings): for my_str in sorted(list(strings), reverse=True): if msg.startswith(my_str): return my_str example_list = {'foo bar', 'foo'} messages = ['foo hello', 'foo bar testing', 'foo foo bar'] for msg in messages: print(check(msg, example_list))
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs