Created a program to calculate sales tax and create a list of the user input to sum to obtain the sales price. Loop should end when 0 is entered. I am getting the following error:
Traceback (most recent call last):
File "/home/Strongheartedpr/4-4.py", line 28, in <module>
price = sumList(list1, len(list1))
TypeError: object of type 'float' has no len()
Code:
print ("Sales Tax Calculator\n")
answer = "y"
while answer == "y":
def calcState(price):
state_tax = .06
return price * state_tax
def displayAnswer(price):
state_tax_amt = calcState(price)
print("Total: ", price)
print('Sales tax: ', state_tax_amt)
print('Total after tax: ', price + state_tax_amt )
list1 = float(input('Enter the price of the purchase: '))
def sumList(list, size):
if (size == 0):
return 0
else:
return list[size - 1] + sumList(list, size - 1)
price = sumList(list1, len(list1))
def main():
displayAnswer(price)
if __name__ == "__main__":
main()
answer = input("\nAgain? (y/n): ")