【发布时间】:2018-04-16 11:07:31
【问题描述】:
我试图找到变量 x 和变量 y 的值,但我无法正确划分它。我总是收到涉及 z 变量的错误。
x = str(input("What was your total: "))
y = str(input("What percentage of a tip would you like to give (15 or 20): "))
z = float(x / y)
print("The tip you will want to give will be: " + z)
input("\n\nPress the enter key to exit")
【问题讨论】:
-
x和y是字符串。你不能把它们分开。 -
z = float(x / y) TypeError: unsupported operand type(s) for /: 'str' and 'str'
标签: python