Question: Hi there I keep getting the TypeError please help thx 32017020 Labu/Test1 Revison page 10 of 101 Dashboard / My courses / 2020 / COMPSCI.130.C.55.2020


Hi there
I keep getting the TypeError
please help
thx
32017020 Labu/Test1 Revison page 10 of 101 Dashboard / My courses / 2020 / COMPSCI.130.C.55.2020 / Labs (20%) / Labo7test1 Reivison estan 10 Not complete Marked out of 1.00 Given a dictionary representing a frequency table of words, write a function called get_ordered_words that will accept the dictionary as a parameter and return a list of the words, ordered by the number of times they appeared (most frequent first), and then alphabetically if they appeared the same number of times, For example: Test Result freq = {'e': 2, 'c': 3, 'a': 2, 'b': 3, 'd': 2, 'f': 1} print(get_ordered_words (freq)) ['b', 'c', 'a', 'd', 'e', 'f'] Answer: (penalty regime: 0,0,5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Precheck Check - Lab06Sorting Jump to. Jump to... Labos Labo8Classes hhilpaaleidum audiane remoodle.mod cuvattempt.ple attempt=25855page&emid=16 *010.py - E:/5S/Lab07/010.py (3.7.3)* File Edit Format Run Options Window Help def get_ordered_words (freq): a_list = freq. items #list of tuples key_list = list (freq, keys O) value_list = list (freq. values O) output_list = ] sorted value list - sorted(value list) sorted_value_list = sorted_value_list.reverse() for element in sorted_value_list: #clcments are the frequency from largest to smallest index_of_sorted_value = value_list. index (element) output_list.append(key_list(index_of_sorted value]) return output_list freq = {'e': 2, 'c': 3, 'a': 2, 'b': 3, 'd': 2, 'f': 1} print (get_ordered_words (freq)) Ln: 19 Col: 30 ospehe seren D A L 12:57 Type here to search A c :: | ENG 22/01/2020 0 s Python 3.7.3 Shell File Edit Shell Debug Options Window Help Python 3.7.3 (v3.7.3:eflec6ed12, Mar 25 2019, 21:26:53) [MSC v. 1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. ============ RESTART: E:/SS/Lab07/Q10.py ================================== ['t', 'e', 'e', 'e', 'c','d'] l'f', 'e ' --- RESTART: E:/SS/Lab07/Q10.py ---------------- >>> =========== RESTART: E:/SS/Lab07/Q10.py ========= Traceback (most recent call last): File "E:/SS/Lab07/Q10.py", line 25, in
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
