Create a function that allows you to move values between directories keys. It should check for: 1) if the specified key is in the dictionary and show ERROR NO SUCH KEY if it does not exist 2) if the value is present in the dictionary and show ERROR NO SUCH VALUE if it doesn't exist 3) if both key and value are in the dictionary, then the function should move value v to another k and return a new dictionary Example: Input: directories = { '1': ['2207 876234', '11-2'], '2': ['10006'], '3': [] } v = '11-2' k = '3' Output: directories = { '1': ['2207 876234'], '2': ['10006'], '3': ['11-2'] }
def move(directories, v, k): if k not in directories: print('ERROR NO SUCH KEY') return directories elif v not in directories[k]: print('ERROR NO SUCH VALUE') return directories else: directories[k].append(v) for key, value in directories.items(): if v in value: value.remove(v) return directories directories = { '1': ['2207 876234', '11-2'], '2': ['10006'], '3': [] } move(directories, '11-2', '3')