Created
July 14, 2013 18:45
-
-
Save pkqk/5995306 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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