Write a program to record the daily expense.
Use a data structure (e.g. a list of tuples) to keep the records of expense, date, and description.
Define 3 functions: write_record, list_records, and total_expense. write_record writes to the data structure, list_records prints out the records, and total_expense returns the total expense.
The function write_record should accept 3 parameters, representing expense, date, and description. Date is an optional parameter with default value being "2020/01/18". Description is also an optional parameter with default value of being "something".
The function list_records has no return value. It should print out all the records, one in a line, in the format as "$100, 2020/01/18, lunch".
The function total_expense returns the total expense, in the type of integer.
Example usage:
>>> write_record(40, '2020/01/16', 'breakfast')
>>> write_record(99, date='2020/01/17')
>>> write_record(300, description='book')
>>> write_record(55)
>>> list_records()
$40, 2020/01/16, breakfast
$99, 2020/01/17, something
$300, 2020/01/18, book
$55, 2020/01/18, something
>>> print(total_expense())
494
[NOTE]
For judging purpose, the code you submit should take 4 strings representing the function calls of write_record from input and execute the function calls using the built-in function exec.
Then call list_records and print the returned value from total_expense at the end.
In short, you should use the following template code and fill in the required parts.
4 lines of string representing the function call of write_record.
4 lines of record printed by list_records() and 1 line of the total expense.