Skip to content

Instantly share code, notes, and snippets.

@saliksyed
Created June 27, 2017 14:18
Show Gist options
  • Save saliksyed/dd539abe22b1d4ab629ba87b8a7d3c39 to your computer and use it in GitHub Desktop.
Save saliksyed/dd539abe22b1d4ab629ba87b8a7d3c39 to your computer and use it in GitHub Desktop.
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