Created
February 27, 2015 17:00
-
-
Save drvinceknight/280edc2ec04e6a7efbf6 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
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