Posted By: Raj
I am typing to get a sale amount (by input) to be multiplied by a defined sales tax (0.08) and then have it print the total amount (sales tax times sale amount).
I run into this error. Anyone know what could be wrong or have any suggestions?
salesAmount = raw_input (["Insert sale amount here n"]) ['Insert sale amount here n']20.99 >>> salesTax = 0.08 >>> totalAmount = salesAmount * salesTax Traceback (most recent call last): File "<pyshell#57>", line 1, in <module> totalAmount = salesAmount * salesTax TypeError: can't multiply sequence by non-int of type 'float'
raw_input returns a string (a sequence of characters). In Python, multiplying a string and a float makes no defined meaning (while multiplying a string and an integer has a meaning:
"AB" * 3 is
"ABABAB"; how much is
"L" * 3.14 ? Please do not reply
"LLL|"). You need to parse the string to a numerical value.
You might want to try:
salesAmount = float(raw_input("Insert sale amount heren"))