Skip to content

Instantly share code, notes, and snippets.

@slapec
Last active January 1, 2021 23:02
Show Gist options
  • Save slapec/df9b15dd63e6bc7eb80064b8730a4708 to your computer and use it in GitHub Desktop.
Save slapec/df9b15dd63e6bc7eb80064b8730a4708 to your computer and use it in GitHub Desktop.
import re
items = ('burger', 'fries', 'chicken', 'pizza', 'sandwich', 'onionrings', 'milkshake', 'coke')
def get_order(s):
words = re.findall('|'.join(items), s, flags=re.IGNORECASE)
words.sort(key=items.index)
return ' '.join(map(str.capitalize, words))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment