Parsons Problem

write some code that will transform the data in the courses list into a list of dictionaries called courses_db. Each dictionary should have the same four keys: dept_code, course_code, section, and instructor. And there should be one dictionary for each of the courses in the original courses list.

  1. In the space below, drag lines of code from the rows on the left to the empty rows on the right.
  2. Arrange the lines of code in the logical order that will produce the desired output.
  3. To indent a line of code, follow the yellow highlighting when positioning it over an empty row.
  4. To run your code, click the Run code button. The output of running your code, including any error messages, will appear in the panel at the bottom
  5. Click the Reset button to clear the code space on the right and start over.

Problem Setup

Assume that the following code has run already in this session.



courses = ['CHEM 1001 10 Mack', 'CHEM 1002, 10 Srinivasan', 'CHEM 1002 11 Mack', 'BISC 1100 10 Liu', 'BISC 1102 10 Thomson', 'PSC 2001 10 Wolters', 'PSC 2001 11 Rath', 'PSC 2001 12 Cho', 'WSTU 6999 10 Cho', 'WSTU 6999 11 Delaney']

Compose your code here

course_info = course.split()
course_dict['section'] = course_info[2]
courses_db.append(course_dict)
course_dict['dept_code'] = course_info[0]
courses_db = []
for course in courses:
print(courses_db)
course_dict = {}
course_dict['instructor'] = course_info[3]
course_dict['course_num'] = course_info[1]

Python output

>>Python output here...