Tell us what’s happening:
I am having trouble generating the check_funds method for the budget class. Based on the error message there seems to be a type error but I am out of my wits in terms of how to go about fixing this. The error message is the following:
Traceback (most recent call last):
File “main.py”, line 12, in
food.transfer(50, clothing)
File “/home/runner/fcc-budget-app/budget.py”, line 21, in transfer
if self.check_funds(amount):
File “/home/runner/fcc-budget-app/budget.py”, line 26, in check_funds
if amount > self.balance:
TypeError: ‘>’ not supported between instances of ‘Category’ and ‘float’
Will be grateful for any help that I can get here…
Thank you so much! That seemed to have solved the issue. I did not know that there was a rule for argument positions. Is there a good resource on this that I could look into?
There are two rules:
First, a function needs to start with positional arguments (those without default values) and after that those with default-values.
Second: declare positional values in the same order they are called
The testing module calls transfer(value, category) - so you broke rule two declaring transfer(self, category, value).
Gotcha. Thank you Jagaya. I found this in a stackoverflow conversation that was also quite helpful.
Positional arguments are arguments that can be called by their position in the function definition. Keyword arguments are arguments that can be called by their name. Required arguments are arguments that must passed to the function. Optional arguments are argument that can be not passed to the function. In python optional arguments are arguments that have a default value .