Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. import difflib
  2. usr_input = 'Rum and Juice'
  3. drinks = ['Jargerbomb', 'Vodka', 'Rum and Coke']
  4.  
  5. def match_ratio(string):
  6. return difflib.SequenceMatcher(None, usr_input, string).ratio()
  7.  
  8. best_match = max(drinks, key=match_ratio)
  9.  
  10. print best_match
  11.  
  12. print [match_ratio(k) for k in drinks]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement