def purchace():
total=0
while keepgoing == ("y" or "Y"):
item= float(input("Enter price of the item")
if (item<=100):
dis=(.15*item)
price=(item-dis)
else:
dis=(.25*item)
price=(item-dis)
total+= item
keepgoing = raw_input("Do you want to add more items? (y/n)")
print("Your total is ",total)
print("Thank you")
def main():
purchase()
main()
第6行存在語法錯誤「if(item < = 100):」它特別強調在冒號「:」,是不是如何使if在Python中的語句?我應該繼續在while循環之前定義嗎?Python While循環(檢查行6)
你'而情況也是錯誤的。 (「y」,「Y」):'。 – chepner