I need help getting my conditional statement to look through array values using a For Loop.
I have the impression that it may because I'm not using b'X' as I am in the other two if statements, but I just can't figure out the right syntax to get this going, and I'm not even sure what the b is doing there anyway.
The R and X keystrokes do execute their code properly, but P, N, D, and Q which are checked as part of the FOR loop, do not.
Token = [['P',0,.01,"Penny"],['N',0,.05,"Nickel"],['D',0,.10,"Dime"],['Q',0,.25,"Quarter"]]
def GetKey(CoinIn): # Recieve a coin, update all total counts and values
if CoinIn == b'R': # Reset All Values and counts to 0
for i in Token:
i[1] = 0
elif CoinIn == b'X': # Exit Request
return('X')
else: # HERE IS WHERE THE CODE BREAKS
for i in Token:
if CoinIn == i[0]:
i[1] += 1
For more context, the entire project is open source on GitHub.