Skip to content

Instantly share code, notes, and snippets.

@pkqk
Created July 14, 2013 18:45
Show Gist options
  • Select an option

  • Save pkqk/5995306 to your computer and use it in GitHub Desktop.

Select an option

Save pkqk/5995306 to your computer and use it in GitHub Desktop.
cocktails = [
(1, 'This is a name'),
(2, 'The beauty beneath'),
(3, 'woo woo'),
(4, 'martinez'),
(5, 'the crow cocktail'),
(6, 'charlie chaplain cocktail'),
(7, 'gin n it')
]
ignore_words = set(['the'])
def alliterates(name):
words = [w for w in name.split() if w not in ignore_words]
if len(words) == 1:
return False
first_letters = set(w[0] for w in words)
return len(first_letters) == 1
def alliterating_names(cocktails):
return [n for n in cocktails if alliterates(n[1])]
print alliterating_names(cocktails)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment