Answered step by step
Verified Expert Solution
Question
1 Approved Answer
creat a new EnhancedBudget class, do the following: add a new class attribute, transactions. This should be initialized when the EnhancedBudget is created and should
creat a new EnhancedBudget class, do the following:
- add a new class attribute, transactions. This should be initialized when the EnhancedBudget is created and should default to being an empty dictionary ({}). This dictionary will have budget categories as its keys and the values associated with each key will be a list of the transactions (in dollars) logged for that category.
- add a new class method, log_transaction, that takes two inputs: category and amount. Using these two inputs, this method should for the following:
- Check to see if the provided category is already in the transactions dictionary.
- If it is, it should append the amount to the list of amounts that already exist in that category.
- If it isn't already in the transactions dictionary, it should create a new list associated with that category key with the amount as the first entry in the list.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started