Applying the Catalogue Entry Function
Now that we have the manage_catalogue_entry()
function, let's see how to use it to manage the entries in a catalogue.
Adding New Entries
To add a new entry to the catalogue, call the manage_catalogue_entry()
function with the "add" action and provide the necessary information:
catalogue = manage_catalogue_entry("add", "Book", "Python Programming Fundamentals", 29.99)
This will add a new entry to the catalogue with the name "Book", description "Python Programming Fundamentals", and price 29.99.
Updating Existing Entries
To update an existing entry in the catalogue, call the manage_catalogue_entry()
function with the "update" action and provide the updated information:
catalogue = manage_catalogue_entry("update", "Book", "Python Programming: A Comprehensive Guide", 39.99)
This will update the description and price of the "Book" entry in the catalogue.
Retrieving Catalogue Entries
To retrieve the details of an entry in the catalogue, call the manage_catalogue_entry()
function with the "retrieve" action and the item name:
catalogue = manage_catalogue_entry("retrieve", "Book")
This will print the details of the "Book" entry, including its name, description, and price.
Handling Invalid Actions
If you call the manage_catalogue_entry()
function with an invalid action, the function will print an error message:
catalogue = manage_catalogue_entry("delete", "Book")
This will output the message "Invalid action. Please use 'add', 'update', or 'retrieve'."
By understanding how to use the manage_catalogue_entry()
function, you can effectively manage the entries in your catalogue, adding new items, updating existing ones, and retrieving their details as needed.