Submit o Unit tests main.py do o E Console Shell Instructions D Run tests I Instructions 01 02 You are given two synonym

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Submit o Unit tests main.py do o E Console Shell Instructions D Run tests I Instructions 01 02 You are given two synonym

Post by answerhappygod »

Submit O Unit Tests Main Py Do O E Console Shell Instructions D Run Tests I Instructions 01 02 You Are Given Two Synonym 1
Submit O Unit Tests Main Py Do O E Console Shell Instructions D Run Tests I Instructions 01 02 You Are Given Two Synonym 1 (275.97 KiB) Viewed 41 times
it is not running the test case
Submit o Unit tests main.py do o E Console Shell Instructions D Run tests I Instructions 01 02 You are given two synonym dictionary files parse through each file line by line and retrieve the data each line will be a word with its synonyms in this format aa OD responsibility authority, control, leadership 1 def file_to_dict(filename): 2 3 dictionary = {} 4 file = open(filename, 'r') 5 lines = file readlines 6 Ist=[] 7 8 fon i in lines: 9 1 =1.replace("-", ") 10 1 Ureplace(" 11 1=uureplace("" 12 Ist append(i) 13 14 for line in ist: 15 tmplst = line.split(',') 16 key = tmplst[@] del (tmplst[0]) 18 value = tmplst 19 dictionary[key]=value; alue; 20 return dictionary 21 22 det main() 23 filename = input() 24 print(file_to_dict(filename) 25 26 y if _name=main" 27 main() your task is to form a dictionary which looks like the below one d = {"responsibility": ["authority", "control", "Leadership"]} Hint: 1. Read the file line by line as strings into a list ist 2. Replace space and with and 'in' with nothing 3. Take the ith string from the list 1st and split them as templst 4. make the oth them of templst as key and remaining as list of values 5. Do the 4th step by going through the other terms of templst and appending them into the dictionary key 6. Repeate the steps 3 and 5 until the len of Istte Windows Go to Set
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply