首页 > 解决方案 > Money Tax and Tip Float Complication

问题描述

I am making a program to find the taxed amount of money and combine that with the tip.

I am working on the tipped amount and intro.

Code:

print "Welcome \nEnter The Amount Of Money For the Transaction"

amount = raw_input

print "Taxed Amount Below\n"
taxed = (amount * float((1.065)))

print taxed

And this is what I get out:

>>> runfile('/home/meyer/.spyder2/temp.py', wdir='/home/meyer/.spyder2')
Welcome 
Enter The Amount Of Money For the Transaction
Taxed Amount Below

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
    execfile(filename, namespace)
  File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
    builtins.execfile(filename, *where)
  File "/home/meyer/.spyder2/temp.py", line 8, in <module>
    taxed = (amount * float((1.065)))
TypeError: unsupported operand type(s) for *: 'builtin_function_or_method' and 'float'
>>> 

I know that I cant multiply by this float, but I cant find any other way. Even MPMath

I am using python 2.7

Thanks In Advance!

标签: pythonpython-2.7currencyraw-input

解决方案


您正在尝试将内置函数乘以浮点数。您必须改为调用该函数来获取一个数字:

amount = float(raw_input())

推荐阅读