-1
我試着寫在課堂上一個項目一個計算器,但保持擊中同一個錯誤:不能用'float'類型的非整型乘序列?
Traceback (most recent call last): File "C:\Users\shane\PythonPrograms\louie.py", line 56, in tax_percent = (price * tax) TypeError: can't multiply sequence by non-int of type 'float'
我的代碼如下。任何人都可以幫我調試嗎?
size_types = {'mini',
'regular',
'large'
}
meat_types = {'pork',
'beef',
'chicken'
}
def price_pork_meal(size):
if size == 'mini':
return 3.00
if size == 'regurlar':
return 4.00
if size == 'large':
return 6.00
else:
return (input('Please try again:'))
return size
def price_beef_meal(size):
if size == 'mini':
return 4.00
if size == 'regular':
return 7.00
if size == 'large':
return 9.00
else:
return (input('Please try again:'))
return size
def price_chicken_meal(size):
if size == 'mini':
return 3.50
if size == 'regular':
return 6.00
if size == 'large':
return 8.00
else:
return (input('Please try again:'))
return size
def final_price(price, tax_percent):
price = size
total_price = price + tax_percent
return total_price
size = (input('Please enter mini, regular, or large:\n'))
price = size
tax = 0.825
tax_percent = (price * tax)
print(final_price(price, tax_percent))
請把您的完整代碼在你的問題 – River
似乎變量'price'是一個'list'或者'tuple',你試圖用'float'乘以它。 – Abdou