Hi Guys,
I am having a problem with a while loop for a tax calculator. You don't have to understand taxes to understand the problem.
Here is the Code. I think that the problem is the lst isnt appending. But there may be more issues that I dont see.
![[Image: tB7wgTF]](https://ibb.co/tB7wgTF)
Thanks in Advance,
Fid
I am having a problem with a while loop for a tax calculator. You don't have to understand taxes to understand the problem.
Here is the Code. I think that the problem is the lst isnt appending. But there may be more issues that I dont see.
class marginal_calc: def __init__(self,value): self.value = value def calculate(self): bracket = [0,12500,50000,150000] percentage = [0,0.2,0.4,0.45] bracket.append(self.value) bracket = [num for num in bracket if num <= self.value] bracket = list(set(bracket)) bracket.sort() p2 = [] count = 0 while count < (len(bracket)-1): p2.append(percentage[count]) count+=1 lst = [] index = 0 while index < len(bracket)-1: a = index if index > 0: b = (bracket[a]-bracket[a-1] )* p2[a-1] lst.append(b) index = index + 1 return('total',sum(lst)) print(marginal_calc(30000).calculate())Here is an image explainig how the code should work.
Thanks in Advance,
Fid