Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/bin/env python3 

2 

3"""Solution to chapter 7, exercise 33: transform_values""" 

4 

5 

6def transform_values(func, a_dict): 

7 """Takes two arguments, a function and a dict. 

8Returns a dict in which the keys are the original 

9dict's keys, but the values are the result of invoking 

10the function on each original value. 

11""" 

12 return {key: func(value) 

13 for key, value in a_dict.items()}