Learn

Code Challenge: Dictionaries

Introduction

This lesson will help you review Python functions by providing some challenge exercises involving dictionaries.

As a refresher, function syntax looks like this:

def some_function(some_input1, some_input2): … do something with the inputs … return output

For example, a function that counts the number of values in a dictionary that are above a given number would look like this:

def greater_than_ten(my_dictionary, number): count = 0 for value in my_dictionary.values(): if value > number: count += 1 return count

And this would produce output like:

>>> greater_than_ten({"a":1, "b":2, "c":3}, 0) 3 >>> greater_than_ten({"a":1, "b":2, "c":3}, 5) 0

### Instructions

When you’re ready to do this series of short function challenges, continue on to the rest of the lesson!