You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.1 KiB

Python Part Time

Reverse Lookup

Overview:

Finding the value from a key is easy: my_dictionary[key]. But what if you only have the value and want to find the key?

There's no built-in function for this - you'll be writing it here.

You will practice these programming concepts we've covered in class:

  • Functions
  • Loops
  • Dictionaries

Deliverables

One .py file with code that solves the problem.

Requirements

You task is to write a function that takes a dictionary and a value, returning the corresponding key.

For example:

state_capitals = {
  "Alaska" : "Juneau",
  "Colorado" : "Denver",
  "Oregon" : "Salem",
  "Texas" : "Austin"
  }

print(reverse_lookup("Denver"))
# Prints Colorado