Exercise

Writing a function to help you

Suppose you needed to repeat the same process done in the previous exercise to many, many rows of data. Rewriting your code again and again could become very tedious, repetitive, and unmaintainable.

In this exercise, you will create a function to house the code you wrote earlier to make things easier and much more concise. Why? This way, you only need to call the function and supply the appropriate lists to create your dictionaries! Again, the lists feature_names and row_vals are preloaded and these contain the header names of the dataset and actual values of a row from the dataset, respectively.

Instructions

100 XP
  • Define the function lists2dict() with two parameters: first is list1 and second is list2.
  • Return the resulting dictionary rs_dict in lists2dict().
  • Call the lists2dict() function with the arguments feature_names and row_vals. Assign the result of the function call to rs_fxn.