Generation

generate functionThu, 15 Dec 2022

Create a function that adds the following variables docnum = '42' doctype = 'multipassport' docowner = 'R2D2' shelf = 3 into lists and dictionaries with the corresponding structures documents = [ {'type': doctype, 'number': docnum, 'name': docowner}, ] directories = { shelf: [] }

def new_doc_add(): docnum = input('Enter the number of your document: ') doctype = input('Enter the type of your document: ') docowner = input('Enter the owner of your document: ') shelf = input('Enter the shelf number: ') documents.append({'type': doctype, 'number': docnum, 'name': docowner}) if shelf in directories: directories[shelf].append(docnum) else: directories[shelf] = [docnum]

Questions about programming?Chat with your personal AI assistant