Generation

generate functionThu, 15 Dec 2022

Create a function that checks if there is a docnum value in the list with the dictionary, and if there is, deletes it, otherwise print Document not found docnum = '10006' documents = [ {'type': 'passport', 'number': '2207 876234', 'name': 'Василий Гупкин'}, {'type': 'invoice', 'number': '11-2', 'name': 'Геннадий Покемонов'}, {'type': 'insurance', 'number': '10006', 'name': 'Аристарх Павлов'} ]

def del_doc_by_num(doc_num): for document in documents: if document['number'] == doc_num: documents.remove(document) return print('Document not found') del_doc_by_num('10006')

Questions about programming?Chat with your personal AI assistant