Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

One day you were interested in comparing the number of words in different languages. Google brought you to Wikipedia: Link to the article. The article

image text in transcribed
One day you were interested in comparing the number of words in different languages. Google brought you to Wikipedia: Link to the article. The article claims that the Korean language has the most number of words in its dictionary (over 1 million), and the English language is # 13 on the list. You decided to change that and move English to the top 10. In order to do that, you need to write a function englishDictionary(letters, n) that creates a new word by concatenating elements from list letters, starting from letters[] through letters[i+n], but only if letters[i] does not start with either "x"or z" In this case, new word is "empty". If there are not enough elements because we reach the end of the list, we concatenate only as many elements as we have. For example, suppose your list is letters ["ma", "le", "zo", "sh", "tip", "pa"], and n 3. In this case: Join letters[0] +letters[1] +letters[2)+letters[3]. Join letters[1) + letters[2] + letters(3] + letters(4]. "empty" is created because letters[2] starts with a z . Join letters[3] +letters[4] letters[5] e Join letters[4] +letters[5] letters[5). You do not need to join anything to letters[5] because there are no values after letters[5). Thus, the result is: [malezosh, lezoshtip, empty, shtippa, tippa, pa) The meaning of the word will also be created by concatenating the same elements, but backwards. "empty" doesn't have a meaning. For example, if you have used ['ma, "le", "zo"1 to create a new word "malezo", then the meaning of it would be "oz el am" Each new word and its corresponding meaning should be stored as a pair of key and value in the new dictionary which will be returned at the end. def english dictionary (letters, n): Return a dictionary with new words. >> letters["alezo"sh"eippa" >>temp engiish dictionary(letters, 3) >>> (key,temp[key) for key in sortemp. keys()) >words"xoxo "yum" lo1","Ypop1 >temp english dictionary(words, 2) >>>I(key,templkey) for key in sorted (temp.keys())1 I(empty, olypop, popy lol, ('ypop popy),'yunlolypop, 'popy lol muy )1 YOUR CODE HERE

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions