嗨,所以我刚开始在学校学习python,但不了解老师的教学,并且我的代码开始运行时遇到了多个错误,该程序是关于某人与在线速度票务系统进行交谈的,它询问多少超出速度限制的人要走,并给予适当的罚款。我收到错误消息,例如,如果此人处于加速极限,则如果他继续执行该代码,则该代码应停止,并且我无法弄清楚他何时再次输入字母会问这个问题,这是我第二次使用堆栈溢出,请不要因为我提出问题的方式降级
fine = []
"""the check_warrant function uses for loop to
check the list if it matches with the drivers' name"""
def check_warrant(name):
for person in warrant:
if person == name:
print(person.upper(), "IS WANTED FOR ARREST!!!")
def enterFine():
individual_fine = 0
validInput = False
while validInput == False:
try:
speedlimit = int(input("Enter speedlimit :"))#local variables
if speedlimit >= 0:
speed = int(input("Enter speed :"))
amountOver = speed - speedlimit
if amountOver > 0:
validInput = True
print("You are over the speed limit")
individual_fine += 630
else:
print("You are driving under the speed limit")
return 0
except ValueError:
print("ERROR: Please enter number values only")
return individual_fine
#Main Routine
for i in range(1):
name = input("Enter the name of the driver? :")
check_warrant(name) #calls the check_warrant function and enter the value name
ind_fine = enterFine()
print("Fine for {} is {}".format(name,ind_fine))
#Main routine
moreInput == "Y"
while moreInput == "Y":
#Ask for input
name = str(input("Enter name: "))
enterFine() #enter fine function
askInput = "X"
while askInput != "Y" and askInput !="N":
askInput = input("Do you wish to enter another speeder (Y/N): ")
if askInput == "N":
moreInput = "N"