1
def main():
        print "This Program will calculate the amount of parking charges by hours using a     given list: "
        ticket = raw_input("Please enter ticket. If lost, Please enter no")
        if ticket in ['No','no','N','n']
        hour = float(input("Enter total hour at parking deck: ")          
        while(hour <= 0 or hour > 24):
        hour = int(input("Enter an integer between 1-24 (hour): "))

上面的代码在第 6 行的单词 while 处有语法错误

4

2 回答 2

1

下面的行中缺少一个括号/大括号。添加大括号,错误应该消失。

hour = float(input("Enter total hour at parking deck: ") 

另外 if 需要一个冒号结尾。以下是更正后的行

if ticket in ['No','no','N','n']:
    hour = float(input("Enter total hour at parking deck: "))   
于 2013-10-16T05:10:43.687 回答
1

开始一个新块的语句,例如if末尾while需要一个分号。

if ...:
 ...
while ...:
 ...

它们的块也需要缩进一级。

于 2013-10-16T05:11:05.627 回答