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.
44 lines
1.1 KiB
44 lines
1.1 KiB
###  Python Part Time
|
|
|
|
<!---
|
|
|
|
Questions? Comments?
|
|
1. Log an issue to this repo to alert me of a problem.
|
|
2. Suggest an edit yourself by forking this repo, making edits, and submitting a pull request with your changes back to our master branch.
|
|
3. Hit me up on Slack @susiremondi
|
|
--->
|
|
|
|
# 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:
|
|
|
|
```python
|
|
state_capitals = {
|
|
"Alaska" : "Juneau",
|
|
"Colorado" : "Denver",
|
|
"Oregon" : "Salem",
|
|
"Texas" : "Austin"
|
|
}
|
|
|
|
print(reverse_lookup("Denver"))
|
|
# Prints Colorado
|
|
```
|