def update(table, id_): """ Updates specified record in the table. Ask users for new data. Args: table (list): list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ new_data = ui.get_inputs( ["TITLE", "PRICE", "MONTH", "DAY", "YEAR"], "Please enter the new data to update" ) if common.confirm_option(): ID = 0 for game in table: if game[ID] == id_: for game_data_index in range(len(new_data)): game[game_data_index + 1] = new_data[game_data_index] return table
def update(table, id_): """ Updates specified record in the table. Ask users for new data. Args: table (list): list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ new_data = ui.get_inputs( ["Name", "Birth year"], "Please enter the new data to update" ) if common.confirm_option(): ID = 0 for person in table: if person[ID] == id_: for person_data_index in range(len(new_data)): person[person_data_index + 1] = new_data[person_data_index] return table
def update(table, id_): """ Updates specified record in the table. Ask users for new data. Args: table (list): list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ new_data = ui.get_inputs( ["NAME", "MANUFACTURER", "YEAR OF PURCHASE", "DURABILITY"], "Please enter the new data to update: " ) if common.confirm_option(): ID = 0 for item in table: if item[ID] == id_: for item_data_index in range(len(new_data)): item[item_data_index + 1] = new_data[item_data_index] return table
def update(table, id_): """ Updates specified record in the table. Ask users for new data. Args: table: list in which record should be updated id_ (str): id of a record to update Returns: list: table with updated record """ new_data = ui.get_inputs( ["Title", "Manufacturer", "Price", "In-stock"], "Please enter the new data to update" ) if common.confirm_option(): ID = 0 for game in table: if game[ID] == id_: for data_index in range(len(new_data)): game[data_index + 1] = new_data[data_index] return table
def add(table): """ Asks user for input and adds it into the table. Args: table (list): table to add new record to Returns: list: Table with a new record """ input_for_new_row = ui.get_inputs( ["Name", "Birth year"], "Please enter product details" ) input_for_new_row.insert(0, common.generate_random(table)) if common.confirm_option(): table.append(input_for_new_row) return table
def remove(table, id_): """ Remove a record with a given id from the table. Args: table (list): table to remove a record from id_ (str): id of a record to be removed Returns: list: Table without specified record. """ if common.confirm_option(): ID = 0 for game in table: if game[ID] == id_: table.remove(game) return table