File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed
Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ import json
2+
3+ from difflib import get_close_matches
4+
5+
6+ data = json .load (open ("data.json" ))
7+
8+ def dictionary (word ):
9+ if word in data :
10+ return data [word ]
11+
12+ elif word .title () in data :
13+ return data [word .title ()]
14+
15+ elif word .upper () in data :
16+ return data [word .upper ()]
17+
18+ elif word .lower () in data :
19+ return data [word .lower ()]
20+
21+ elif len (get_close_matches (word , data .keys ())) > 0 :
22+ print ("did you mean %s insteads" % get_close_matches (word ,data .keys ())[0 ])
23+ MATCH = input ("enter y for and n for no : " )
24+
25+ if MATCH == "y" :
26+ return data [get_close_matches (word ,data .keys ())[0 ]]
27+
28+ elif MATCH == "n" :
29+ print ("this word is not avail dictionary." )
30+
31+ else :
32+ print ("you input not match to y or n." )
33+
34+
35+ else :
36+ print ("this word is not avail in dictionary." )
37+
38+
39+ word = input ("Enter the word : " )
40+ p = dictionary (word )
41+
42+ if type (p ) == list :
43+ for item in p :
44+ print (item )
45+ else :
46+ print (p )
Original file line number Diff line number Diff line change 1+ import json
2+ def dictionary ():
3+
4+ data = json .load (open ("data.json" ))
5+
6+ x = input ("Enter the word : " )
7+
8+ v = x .lower ()
9+ if v in data :
10+ return data [v ]
11+ else :
12+ print ("this word is not available" )
13+ return dictionary ()
14+ print (data [v ])
15+ dictionary ()
You can’t perform that action at this time.
0 commit comments