Skip to content

Commit 6ec3094

Browse files
committed
Merge branch 'shubhmrj-patch-1'
2 parents 8894f4c + 522677d commit 6ec3094

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

Project 04/data.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

Project 04/practise.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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)

Project 04/question.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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()

0 commit comments

Comments
 (0)