Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement