Question: i am haveing these errors TypeError: 'bool' object is not iterable File / tmp / test . py , line 7 7 ,

i am haveing these errors "TypeError: 'bool' object is not iterable" "File "/tmp/test.py", line 77, in testShowVerifier
expected = machineCorrect.showVerifier(verifier)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/machineCorrect.py", line 66, in showVerifier
verifierStr =[["X" if y else "O" for y in x] for x in verifier[1]]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/machineCorrect.py", line 66, in
verifierStr =[["X" if y else "O" for y in x] for x in verifier[1]]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" The turn history output doesn't match! Pay careful attention to the spaces
We expected:
xyz A B C D E
------------------
124 O X X
214 O X X
351 X X X
But was:
xyz A B C D E
------------------
124 O X X
214 O X X
351 X X X # Probably should put a few functions hereabouts
def inputCard(filename):
with open(filename,'r') as a:
lines = a.readlines()
b = lines[0].strip()
verifiers =[[bool(int(number)) for number in line.strip().split(',')] for line in lines[1:]]
return (b, verifiers)
def getVerifierInput(input_: str)-> list:
character = input_.lower().split(',')
indices =[ord(chars)- ord('a') for chars in character]
return sorted(indices)
def guessToIndex(guess: int)-> tuple:
with open("verifierAddress.in",'r') as a:
lines = a.readlines()
for line in lines:
guess_value, x, y = line.strip().split(',')
if int(guess_value)== guess:
return (int(x), int(y))
return None
def checkVerifier(gameCard: tuple, guess: int)-> bool:
_, verifiers = gameCard
x, y = guessToIndex(guess)
return verifiers[x][y]
def listCriteria(gameCards: list)-> str:
criteria_= "You have {} criteria
".format(len(gameCards))
for index, gameCard in enumerate(gameCards):
criterion = gameCard[0]
criteria_+="{}){}
".format(chr(65+ index), criterion)
return criteria_.strip()
def showTurnHistory(guesses: list, history: list)-> str:
headers ="xyz A B C D E
------------------"
rows =[]
for guess, res in zip(guesses, history):
row ="{:03d}".format(guess)
row +=''.join(['' if r ==0 else 'X ' if r ==1 else 'O ' for r in res]).rstrip('
')
rows.append(row.rstrip())
return headers +"
"+"
".join(rows)
def showVerifier(verifier):
result =[]
for row in verifier:
result.append(''.join(['X' if cell else 'O' for cell in row]).strip('/n'))
return '
'.join(result).rstrip()
if __name__=="__main__":
# This is not part of the tests, so you can use this
# to help check your code is working.
pass

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!