Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 类型错误:can';t将序列乘以类型为'的非整数;浮动';错误I';我什么都试过了 询问总价、税金和小费。然后将它们相加,得出总价。_Python_Python 3.x_Syntax - Fatal编程技术网

Python 类型错误:can';t将序列乘以类型为'的非整数;浮动';错误I';我什么都试过了 询问总价、税金和小费。然后将它们相加,得出总价。

Python 类型错误:can';t将序列乘以类型为'的非整数;浮动';错误I';我什么都试过了 询问总价、税金和小费。然后将它们相加,得出总价。,python,python-3.x,syntax,Python,Python 3.x,Syntax,我读了很多文章,但我无法修复。有人能帮我吗?读取的输入是一个字符串,这是一个序列,不能被浮点数乘以 int(price) 解决它。Python3函数返回一个字符串 您已尝试float*string+string+string total= price*percentage + price + tip TypeError: unsupported operand type(s) for +: 'float' and 'str' 你可以这样修理 from time import sleep

我读了很多文章,但我无法修复。有人能帮我吗?

读取的输入是一个字符串,这是一个序列,不能被浮点数乘以

int(price)
解决它。

Python3函数返回一个字符串

您已尝试
float*string+string+string

total= price*percentage + price + tip

TypeError: unsupported operand type(s) for +: 'float' and 'str'
你可以这样修理

from time import sleep 
def getprice():
    return float(input("What's the price of your bill?").lower())

price = getprice()

def gettax():
    return float(input("What's the restaurant's tax percent?").lower())

tax = gettax()

def gettip():
    return float(input("How much tip do you want to leave?"))

tip = gettip()

percentage = tax / 100
total= price*percentage + price + tip

print(total)

是的,你需要把corrs变量转换成int或float。非常感谢,我终于明白我的错误了。我很笨,谢谢!
from time import sleep 
def getprice():
    return float(input("What's the price of your bill?").lower())

price = getprice()

def gettax():
    return float(input("What's the restaurant's tax percent?").lower())

tax = gettax()

def gettip():
    return float(input("How much tip do you want to leave?"))

tip = gettip()

percentage = tax / 100
total= price*percentage + price + tip

print(total)