如何將2.50添加到成本中?添加一個帶有2位小數的數字給變量(2.50)
現在,它只是打印出來爲2
cost = 0.00
r = open("toppings.txt")
bases = ["small","medium","large"]
toppings = ["Pepperoni","Chicken","Cajun Chicken","Mushrooms",
"Red Onions","Sweetcorn","Ham","Cheese","Spicy Minced Beef",
"Anchovies","Tuna","Peppers","Jalapenos","Green Chillies"] #0-13
def small():
current = cost + 2.50
print("Your current total cost is " + "£" + str(int(current)))
刪除int(current)並直接使用str(current)。 –
剛剛刪除int() – DZDomi
'print(「你目前的總費用是£%2f」%current)'' – Bodhi94