My brief requires me to create a method that
accepts an amount and description. If no description is given, it should default to an empty string. The method should append an object to the ledger list in the form of {"amount": amount, "description": description}.
I have therefore created this function:
def deposit(self,amount,description):
if description == "":
newdict = {"amount":amount,"description":""}
self.ledger.append(newdict)
else:
newdict = {"amount":amount,"description":description}
self.ledger.append(newdict)
However, the test clothing.deposit(25.55)
clearly only uses one argument, the amount, and expects me to leave a blank description, but as is it returns the error TypeError: deposit() missing 1 required positional argument: 'description'
. But if a description is required, I also have to be ready to use it. How do I setup my method so it can use the extra argument, description, but if it isn't given it can safely ignore it?