Skip to content

Instantly share code, notes, and snippets.

@drvinceknight
Created February 27, 2015 17:00
Show Gist options
  • Save drvinceknight/280edc2ec04e6a7efbf6 to your computer and use it in GitHub Desktop.
Save drvinceknight/280edc2ec04e6a7efbf6 to your computer and use it in GitHub Desktop.
import difflib
usr_input = 'Rum and Juice'
drinks = ['Jargerbomb', 'Vodka', 'Rum and Coke']
def match_ratio(string):
return difflib.SequenceMatcher(None, usr_input, string).ratio()
best_match = max(drinks, key=match_ratio)
print best_match
print [match_ratio(k) for k in drinks]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment