在運行時遇到了一些麻煩。基本上我只想得到一個金額,如果它超過50免費送貨,少於收取額外10美元。我繼續得到關於將float轉換爲str隱含的錯誤?我認爲我的意見應該被認爲是一個浮動?爲什麼我無法隱式地將float轉換爲str?
#declare flags
shippingCharge = 10
freeShipping = False
#Get number and convert to float?
purchaseAmount = float(input("\nHow much is the purchase amount? "))
if (purchaseAmount) >= 50 :
freeShipping = True
print("Your purchase amount is " + purchaseAmount + "$ and shipping is free!")
else :
print("Your purchase amount is " + purchaseAmount + "$ and shipping is " + shippingCharge + "$.")
purchaseAmount = shippingCharge + purchaseAmount
print("Your new total is " + purchaseAmount)
print ("Have a nice day and thank you for shopping with us.")
你可以通過谷歌搜索你的問題的標題得到答案。 – TigerhawkT3