Generation

generate functionThu, 15 Dec 2022

Refine the function below to handle errors 1) if shelf variable is not found in directories, it will show ERROR NO SUCH KEY 2) if doc variable is not found in directories, it will show ERROR NO SUCH VALUE def change_shelf(data): docnum = '11-2' shelf = '3' if list(docnum) in data.values(): print('Error') for key, val in data.items(): for doc in val: if doc == docnum: data[shelf].append(doc) data[key].remove(doc) print('OK') return data

def change_shelf(data): docnum = '11-2' shelf = '3' if list(docnum) in data.values(): print('Error') for key, val in data.items(): for doc in val: if doc == docnum: data[shelf].append(doc) data[key].remove(doc) print('OK') return data

Questions about programming?Chat with your personal AI assistant