forked from Bhavya1912/Hacktober2k22
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdictionary.py
34 lines (30 loc) · 1018 Bytes
/
dictionary.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json
from difflib import get_close_matches
data = json.load(open("data.json"))
def translate(word):
word = word.lower()
if word in data:
return data[word]
elif word.title() in data:
return data[word.title()]
elif word.upper() in data:
return data[word.upper()]
elif len(get_close_matches(word , data.keys())) > 0 :
print("did you mean %s instead" %get_close_matches(word, data.keys())[0])
decide = input("press y for yes or n for no")
if decide == "y":
return data[get_close_matches(word , data.keys())[0]]
elif decide == "n":
return("pugger your paw steps on wrong keys ")
else:
return("You have entered wrong input please enter just y or n")
else:
print("pugger your paw steps on wrong keys")
word = input("Enter the word you want to search")
output = translate(word)
if type(output) == list:
for item in output:
print(item)
else:
print(output)
else :