Mar-19-2019, 03:08 PM
(Mar-19-2019, 02:34 PM)buran Wrote: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))
Ah, that's what I was looking for. Thanks :)