This elif(a == True and r[0] == 3 and r[1] == 4 or 7):
will always evaluate to True because 7
is "truthy". You probably Did you mean or r[1] == 7
.? And once an or
introduced, the expression will likely need parentheses. Same goes for the subsequent elif.