Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

When is financial information considered understandable?

Answered: 1 week ago