I am wondering if there is a better way to do what I did in the method addMoneyToCategory. I want to be able to have the name of the attribute as a parameter for the method and then add an integer to that attribute.
class Budget:
def __init__(self, food = 0, clothing = 0, entertainment = 0):
self.Food = food
self.Clothing = clothing
self.Entertainment = entertainment
def addMoneyToCategory(self, category, amount):
if category == "Food" or category == "food":
self.Food += amount
if category == "Clothing" or category == "clothing":
self.Clothing += amount
if category == "Entertainment" or category == "entertainment":
self.Entertainment += amount
i1 = Budget()
i1.addMoneyToCategory("Food", 20)