Question: I am having trouble with a programming assignment. Although this code runs well without errors, I am having a problem with getting it to compute

I am having trouble with a programming assignment.

Although this code runs well without errors, I am having a problem with getting it to compute the results that my professor said it has to produce.

''' HoneyDo: Saving Your Relationship One Program at a Time by: Robby Osborne 1/28/2023 CS-2343: Advanced Scripting ''' def read_file(file_name): with open(file_name, 'r') as f: return [line.strip() for line in f] def reorder_groceries(groceries, canonical): return sorted(groceries, key=lambda x: canonical.index(x)) if __name__ == '__main__': groceries = read_file('groceries.txt') canonical = read_file('canonical.txt') print('Your Original Order:') print(*groceries, sep=' ') reordered_groceries = reorder_groceries(groceries, canonical) print('Your canonical Order:') print(*reordered_groceries, sep=' ')

Is there a way to modify it so that instead of producing this result.....

I am having trouble with a programming assignment. Although this code runs

It produces this result, where there is a space between the separate orders?

well without errors, I am having a problem with getting it to

Your Original Order: milk bread onions cereal ice cream toothpaste apples frozen pizza Your canonical Order: apples onions bread cereal toothpaste frozen pizza milk ice cream The output of the program is below: Your Original Order: milk bread onions cereal ice cream toothpaste apples frozen pizza Your canonical Order: apples onions bread cereal toothpaste frozen pizza milk ice cream

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!