Skip to content

Instantly share code, notes, and snippets.

@mdwhatcott mdwhatcott/mnemonic.py
Last active Jan 2, 2016

Embed
What would you like to do?
Here's some Python code to convert a passage of text into first-letter sequences to facilitate memorization:
def first_letter_mnemonic(text):
words = text.split()
letters = []
for word in words:
letters.append(word[0])
if word[-1] in ',-': # inline punctuation
letters.append(word[-1])
elif word[-1] in '.;:?!': # delimiting punctuation
letters.append(word[-1] + ' ')
return (''.join(letters)).strip()
print first_letter_mnemonic('<paste_verse_here>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.