I'm currently having a problem in python, what I am trying to do is go through 6 arrays checking if there is a negative number or not and then adding one to the corresponding variable.
I've tried various things to fix this however there is no real documentation that I can find online that will help me
BusA = ["-1","1","-1","1"]
BusB = ["-1","1","-1","1"]
BusC = ["-1","1","-1","1"]
BusD = ["-1","1","-1","1"]
BusE = ["-1","1","-1","1"]
BusF = ["-1","1","-1","1"]
Buses = "ABCDEF"
BusALate, BusBLate, BusCLate, BusDLate, BusELate, BusFLate = 0, 0, 0, 0, 0, 0
for c in Buses:
Array = eval("Bus" + str(c))
for i in Array:
if(int(i) < 0):
eval("Bus"+c+"Late") += 1
print(BusALate, BusBLate, BusCLate, BusDLate, BusELate, BusFLate)
If possible I just need a way to format the variable in the if so that it can progressively go through changing it to BusALate, BusBLate etc... and adding when it has found the negative number.
dict:busses = {"A": [-1, 1, -1, 1], B: [....], ...}and integers, if your values are meant to be numbers. So, you would also havebusses_late = {A: 0, ...}