Question: Write a program that reads from a file called dictionary.txt which contains pairs of English and translated words separated by a comma ( , )
Write a program that reads from a file called dictionary.txt which contains pairs of English and translated words separated by a comma and builds a dictionary with them. Your program should then read in lines of text from the user until a blank line and print out a translated sentence, where each word has been looked up in the dictionary.
The data in dictionary.txt will look like this:
dictionary.txt
afternoon,wurajiwuraji
I,ngaju
bird,jirripirdi
like,kujapiya
dance,jukapinyi
python,malilyi
laugh,ngarlarrimi
wengalipa
The first line in this dictionary.txt file means that the English word afternoon should be translated as wurajiwuraji.
Your program should work like this:
English: I like python
ngaju kujapiya malilyi
English: we laugh
ngalipa ngarlarrimi
English:
The dictionary provided will have all the words required for the translation in the correct case, and include no punctuation. The contents of dictionary.txt will change between test cases, so be sure you don't hard code in these example translations into your program!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
