MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / translate

Function translate

Dictionary/dictionary.py:28–41  ·  view source on GitHub ↗
(word, file)

Source from the content-addressed store, hash-verified

26
27#finding correct match
28def translate(word, file):
29 word = word.lower()
30 if word in file:
31 return file[word], None
32 elif word.title() in file:
33 return file[word.title()], None
34 elif word.upper() in file:
35 return file[word.upper()], None
36 else:
37 matches = get_close_matches(word, file.keys())
38 if len(matches) > 0:
39 return f"Did you mean '{matches[0]}' instead?", matches[0]
40 else:
41 return "The word does not exist. Please double-check it.", None
42
43def on_search():
44 word = entry.get().strip()

Callers 3

on_searchFunction · 0.85
suggestFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected