-5
我完全不Python的餐廳價格+提示
bill = float(input("How much did the meal cost? "))
people = input("How many people are available to pay? ")
if bill < 50:
bill2 = 1 * bill+10
else:
bill2 = 1 * bill+20
print("Between everyone the meal costs", bill2/people)
ERROR:
print("Between everyone the meal costs", bill2/people)
TypeError: unsupported operand type(s) for /: 'float' and 'str'
你需要將人員轉換爲int –
您使用了'float'將一個輸入字符串轉換爲數字,但不能將另一個輸入字符串轉換爲數字。 –
錯誤實際上給了你答案,如果你閱讀它......它說你試圖用一個字符串(float/str)分隔一個float,並且這種操作是不被支持的。所以,你的除數是一個字符串,它應該是一個數字。修復它,它會工作。 – zvone