forked from zapellass123/OpenEmailGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole_dictionary.py
More file actions
42 lines (35 loc) · 1.11 KB
/
console_dictionary.py
File metadata and controls
42 lines (35 loc) · 1.11 KB
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
35
36
37
38
39
40
41
42
import json
from difflib import get_close_matches
data = json.load(open("./data.json"))
run = True
def dictionary(word):
word = word.lower()
if word in data:
return data[word]
elif len(get_close_matches(word, data.keys()))>0:
usr = input("Did you mean %s instead. Enter y if yes else n" % get_close_matches(word, data.keys())[0])
if usr == "y":
return data[get_close_matches(word, data.keys())[0]]
elif usr == "n":
return "Word not found. Check the word."
else:
return "We didn't understand your entry."
else:
return "Word not found. Check the word."
print("<<<<<<<<< Console Dictionary using Json module >>>>>>>>")
while run:
word = input("Enter a word: ")
print("\n")
w = dictionary(word)
for i in w:
print(i)
print("\n")
userinput = int(input("Choose the below option \n 1. For Continue \n 2. For exit press \n "))
if userinput == 1 :
run = True
elif userinput == 2 :
run = False
else:
print("Input is not correct.")
run = False
print("Exiting....")