嗨我是新來的蟒蛇,我正在練習通過一個簡單的計算器。 該方案可以讓我輸入數值爲一頓,稅和小費但這樣做的計算,當我得到這個錯誤:簡單的Python計算器
Traceback (most recent call last):
File "C:/Users/chacha04231991/Desktop/pytuts/mealcost.py", line 5, in <module>
meal = meal + meal * tax
TypeError: can't multiply sequence by non-int of type 'str'
的是代碼:
meal = raw_input('Enter meal cost: ')
tax = raw_input('Enter tax price in decimal #: ')
tip = raw_input('Enter tip amount in decimal #: ')
meal = meal + meal * tax
meal = meal + meal * tip
total = meal
print 'your meal total is ', total
'raw_input'的結果是'str'。 – alexvassel