# Database thingy # Simply store records as dictionaries with name, address and phone-number # fields and store them in a main database (a list) # construct record dictionary and add to database list def AddRecord(name, address, phone_number): entry = {'name': name, 'address': address, 'phone-number': phone_number} database.append(entry) # search for phrase in name, address or phone-number of each record # and print if found def SearchForRecord(phrase): for record in database: if phrase in record.values(): PrintRecord(record) # print a record def PrintRecord(recordname): print recordname['name'] print recordname['address'] print recordname['phone-number'] print # show all records def ListRecords(): for record in database: PrintRecord(record) # delete record matching phrase def DeleteRecord(phrase): for record in database: if phrase in record.values(): database.remove(record) # make a new database database = list() AddRecord("Ernie", "Boleveien 22", "99339922") AddRecord("Olav", "Boleveien 4", "99339922") DeleteRecord("Olav") ListRecords()