-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript54_Project_01_Companion_Dictionary.py
More file actions
44 lines (38 loc) · 1.47 KB
/
Script54_Project_01_Companion_Dictionary.py
File metadata and controls
44 lines (38 loc) · 1.47 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
43
44
# In the name of God
# Mohammad Hossein Zehtab
# python-evens-17
# Project 01: Companion Dictionary
word_num = int(input('Number of words that exist in Dictionary: '))
word_list = list()
cdvalues = list()
compdict = dict()
count = -1
for _ in range(word_num):
word_list = input('\nEnter your word and its three meanings\
in English, French and Germany respectively\
separated by space:\n')
wl = word_list.split()
compdict[wl[0]] = wl[1:]
cv = list(compdict.values())
for m in range(len(cv)):
for n in range(len(cv[m])):
cdvalues.append(cv[m][n])
# =============================================================================
# cdvalues.append(cv[m, n] for m in range(len(cv))\
# for n in range(len(cv[m])))
# =============================================================================
sentence = input('\nEnter the sentence you want to translate:\n')
sl = sentence.split()
for s in sl:
count += 1
if s in cdvalues:
for i in compdict:
if s in compdict[i]:
key = i
# =============================================================================
# key = [i for i in compdict if s in compdict[i]]
# =============================================================================
sl[count] = str(key)
#print(sl) Debugging
else: continue
print('\n\nThe translated sentence is:\n', ' '.join(sl))