【发布时间】:2014-10-19 01:41:43
【问题描述】:
这是我的程序,由于某种原因,我一直收到语法错误,请帮我解决这个问题
#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")
【问题讨论】:
-
您在
while语句之前的Syntel = str(input(...行上缺少两个 右括号。你的缩进很乱,让我们很难对你的帖子说太多,而且你没有包含实际的错误信息。 -
第二次打印时出现语法错误
-
再看前一行。您缺少更多右括号。
-
修复了这个问题,现在在我的第一个打印语句中的“is”之后的引用出现错误
-
这不是交互式调试服务;我已经投票结束您的问题,因为拼写错误对未来的访问者没有用处。
标签: python syntax while-loop