2014-10-19 57 views
-3

這是我由於某種原因,我一直得到的,而語法錯誤程序,請排序這幫助我蟒蛇測試前做,而語法錯誤

#Variables 
Destination = " " 
MilesDest = 0 
MPG = 0 
GallonCost = 0 
GallonsNeeded = 0 
GasCost = 0 
Syntel = " " 

#Below begins Do-While pre-test 
while Syntel != "No": 
    Syntel = str(input("would you like to run this program?(Yes/No)(Case-Sensitive) ")) 
    Destination = str(input("Enter the name of your destination: ")) 
    MilesDest = float(input("Enter the amount of miles between your starting point and your destination: ")) 
    MPG = float(input("Enter the current MPG your car gets: ")) 
    GallonCost = float(input("Enter the current cost for a gallon of gas: ")) 
    GallonsNeeded = MilesDest/MPG 
    GasCost = GallonCost*GallonsNeeded 
    print("The number of gallons it takes to get to ",Destination, " is ",GallonsNeeded) 
    print("The cost of the trip to ",Destination, " is $",GasCost) 
#Salutation 
print("Thank you for using my program, good bye") 
+0

您在'Syntel = str(輸入'...'行之前的'while'語句之前缺少* 2 *關閉括號。您的縮進是一團糟,使我們很難說出您的帖子, – 2014-10-19 01:48:47

+0

在我的第二個打印中出現語法錯誤 – Atom 2014-10-19 01:49:39

+0

再一次查看上一行你錯過了更多的右括號 – 2014-10-19 01:50:10

回答

0

應該是while Syntel != "No":。缺少:

您還遺漏Syntel =行上的右括號))

請注意,一旦您糾正該問題,程序將永遠運行。

+0

更新:現在在第二次打印時出現語法錯誤 – Atom 2014-10-19 01:45:40

+0

常規語法錯誤調試提示:如果您在特定行上看到語法錯誤,請查看上一行。 – 2014-10-19 01:52:05