Created
June 27, 2017 14:18
-
-
Save saliksyed/dd539abe22b1d4ab629ba87b8a7d3c39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_dictionary = { | |
"A": 8, | |
"B": 2, | |
"C": 99, | |
"D": 1, | |
"E": 99, | |
"F": None | |
} | |
print my_dictionary.values() | |
print my_dictionary.keys() | |
for key in my_dictionary: | |
print key | |
print my_dictionary[key] | |
def find(to_search, number): | |
found_keys = [] | |
for key in my_dictionary: | |
if my_dictionary[key] == number: | |
found_keys.append(key) | |
return found_keys | |
print find(my_dictionary, 1) | |
print find(my_dictionary, 99) | |
if len(find(my_dictionary, 6)) == 0: | |
print "6 was not found!" | |
print find(my_dictionary, None) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment