我正在尝试编写一个函数(在Python 3.4中),该函数将允许用户对将显示哪个输出做出选择。我的第一条elif线不断被标记为无效语法。我不确定我做错了什么。这里是我的代码:Elif导致语法错误
def questionFunction() :
q1=input('Would you like to: \n1. Submit Input and see costs \n2. View Summary Data \n3. Reset Summary Data \n4. Exit \n Input Corresponding Number Choice here: ')
if q1 == 1:
print ("Cost = $" + format(str(costFunction()), '.4'))
print ("Shipping Cost = $" + format(str(shippingFunction()), '.4'))
print ("Total Cost = $" + format(str(totalCostFunction()), '.4')
elif q1 == 2:
print ("User Count = " +str(count))
print ("Total Revenue = $" + format(str(totalrevenue), '.4'))
elif q1 == 3:
count = 0
totalrevenue = 0
else
print ("This program will now close")
冒号在else子句中缺失 – xecgr 2014-12-02 06:16:18
您错过了关闭''''。 4在你的第一个'elif'之前打开3关闭行。 – halex 2014-12-02 06:16:49
谢谢!那是它造成的。 – NZS 2014-12-02 06:30:25