Python上的语法错误无效

时间:2018-03-11 21:16:25

标签: python python-3.x syntax syntax-error

warrants = ["Adela","Arya","The Big D","Wei Xuen","Rebecca"]
Fines = []
totalFines= 0

def enterFine():
global totalFines

name = input("Enter the full name of the driver: ")
checkwarrant(name)

validInput = False
while validInput == False:
    try:
        speedlimit = int(input("Enter the speed limit across your area :"))
        speed = int(input("Enter the speed of the driver : "))
        amountOver = speed - speedlimit

        if amountOver > 0:
            validInput = True

            if amountOver < 10:
                print("This person should be charged $30")
                totalFines +=30
            elif amountOver < 15:
                print("This person should be charged $45")
                totalFines +=45
            elif amountOver < 20:
                print("This person should be charged $60")
                totalFines +=60
            else:
                print("This person is to be charged $420")

            fines.append([name, amountOver])
        else:
            print("Error")

    except:
        print("Error")

def checkWarrant(name):
for person in warrants:
    if person == name:
        print(person.upper(),"is wanted for using Hooktronic cheats")

def printsummary():
print("Total Fines for today :" , len(fines))
for number in range(0, len(fines)):
    print(number +1, ") Name: ", fines[number][0],"  Amount Over Limit: $", 
fines[number][1]
print("Total amount of fines: $", totalFines)

moreInput = "Y"
while moreInput == "Y":

  enterFine()

  askIntput = "X"
  while askInput != "Y" and askIntput != "N":
      askInput = input("Do you wish to enter another person to the database?
(Y/N): ")

  if askInput == "N":
      moreInput = "N"

printsummary()

嗨,我对此代码有错误,当我运行此程序时,它会出现无效的语法消息。如果你们帮帮我的话会很高兴。谢谢 嗨,我有这个代码的错误,当我运行这个程序时,它会出现一个无效的语法消息。如果你们帮帮我的话会很高兴。谢谢嗨,我有这个代码的错误,当我运行这个程序时,它会出现一个无效的语法消息。如果你们帮帮我的话会很高兴。谢谢嗨,我有这个代码的错误,当我运行这个程序时,它会出现一个无效的语法消息。如果你们帮帮我的话会很高兴。谢谢嗨,我有这个代码的错误,当我运行这个程序时,它会出现一个无效的语法消息。如果你们帮帮我的话会很高兴。谢谢嗨,我有这个代码的错误,当我运行这个程序时,它会出现一个无效的语法消息。如果你们帮帮我的话会很高兴。谢谢嗨,我有这个代码的错误,当我运行这个程序时,它会出现一个无效的语法消息。如果你们帮帮我的话会很高兴。谢谢

1 个答案:

答案 0 :(得分:0)

您的问题存在很多问题:

1)您的代码没有正确缩进

2)你故意在你的问题中粘贴了很多不相关的文字。

3)您没有提供错误的堆栈跟踪

您的代码问题是这一行:

print(number +1, ") Name: ", fines[number][0],"  Amount Over Limit: $", fines[number][1]

最后没有结束语)