У меня возникли проблемы с моей программой python, поскольку она не помещает машины в ограничение скорости в мой «незаконный» список. Почему это происходит? Я также был бы признателен, если бы вы также опубликовали решение.Почему моя программа python не работает?
#start
Illegal=[]
Legal=[]
Count = 1
DIST = 100
TIME = 0
SPEED = 0
def SpeedCheck(TIME):
global DIST
SPEED=(DIST/float(TIME))
#here is a variable i made to make the program more simple
print (" Welcome to the Speed check calculator")
print ("\n")
#program asks the user to add information needed
LIMIT=int(input ("Speed limit (M/S): "))
VAR=int(input ("How many (M/S) should be allowed over the limit?: "))
LIMIT=LIMIT+VAR
while Count==1:
REG = input ("Enter Registration number: ")
TIME =int(input("Enter the time that the vehicle was in the zone in seconds (e.g. 1min= 60): "))
SpeedCheck(TIME)
#variable used
if SPEED>LIMIT:
Illegal.append(REG)
elif SPEED<=LIMIT:
Legal.append(REG)
#desicion
Count=Count-1
Count=int(input("Press 1 to continue or 0 to move on: "))
print ("\n")
option=input("Press P to print Legal and illegal cars: ")
if option=="p":
print ("Legal: \n")
print (Legal)
print ("\n \n")
print ("Illegal: \n")
print (Illegal)
print("\n Thank you for using the program, Goodbye.")
#end
Не могли бы вы, пожалуйста, выбрать более подходящее название для вашего вопроса? Также исправьте ошибки подсветки синтаксиса в начале кода. –
Прочтите [Руководство по стилю для кода Python] (https://www.python.org/dev/peps/pep-0008/). – Matthias