Zipping dictionaries

For this exercise, you'll use what you've learned about the zip() function and combine two lists into a dictionary.

These lists are actually extracted from a bigger dataset file of world development indicators from the World Bank. For pedagogical purposes, we have pre-processed this dataset into the lists that you'll be working with.

The first list feature_names contains header names of the dataset and the second list row_vals contains actual values of a row from the dataset, corresponding to each of the header names.

This exercise is part of the course

Python Toolbox

View Course

Exercise instructions

  • Create a zip object by calling zip() and passing to it feature_names and row_vals. Assign the result to zipped_lists.
  • Create a dictionary from the zipped_lists zip object by calling dict() with zipped_lists. Assign the resulting dictionary to rs_dict.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Zip lists: zipped_lists
zipped_lists = ____

# Create a dictionary: rs_dict
rs_dict = ____

# Print the dictionary
print(rs_dict)