-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
35 lines (27 loc) · 913 Bytes
/
main.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
35
import csv
def intro():
print('Welcome to the Spanish and French translator app.\nPlease enter an English word and hit Enter.')
print('\nType "done" at any time to exit.')
def exit():
print('\nThank you for using the translator app! Have a great day!')
translations = {}
with open("translations.csv", "r", encoding="utf-8") as words:
reader = csv.DictReader(words, delimiter=",")
for line in reader:
english = line["English"].lower()
spanish = line["Spanish"].lower()
french = line["French"].lower()
translations[english] = [spanish, french]
done = False
intro()
while not done:
word = input("\nType an English word to translate: ")
word = word.lower()
if word == "done":
done = True
exit()
elif word in translations:
print(f'\nSPANISH: {translations[word][0]}')
print(f'\nFRENCH: {translations[word][1]}')
else:
print("\nTranslation is not known")