from collections import OrderedDict
def main():
dictionary = OrderedDict()
dictionary["one"] = ["hello", "blowing"]
dictionary["two"] = ["frying", "goodbye"]
for key in dictionary:
print key, dictionary[key]
user_input = raw_input("REMOVE BUILDINGS ENDING WITH ING? Y/N")
if user_input == ("y"):
print ""
for key in dictionary:
for x in dictionary[key]:
if ("ING") in x or ("ing") in x:
del dictionary[key][x]
print ""
for key in dictionary:
print key, dictionary[key]
main()
I am attempting to remove any item with "ing" in it from all keys within a dictionary, example "blowing" from the key "one" and "frying" from the key "two".
The resulting dictionary would go from this:
one ['hello', 'blowing'], two ['frying', 'goodbye']
to this:
one ['hello'], two ['goodbye']