def update_view(puzzle: str, view: str, guessed_letter: str) -> str: """Return a string that gives a new view of the puzzle. Each occurrence in the puzzle of the guessed_letter is revealed. >>> update_view('apple', '^^^le', 'a') 'a^^le' >>> update_view('apple', '^^^le', 'z') '^^^le' """ new_view = '' for i in range(len(puzzle)): new_view = new_view + \ pf.update_letter_view(puzzle, view, i, guessed_letter) return new_view
def test_update_letter_view_3(self): actual = pf.update_letter_view("where's waldo?", "where's wa^do?", -4, "a") self.assertEqual(actual, "^")
def test_update_letter_view_2(self): actual = pf.update_letter_view("where's waldo?", "where's ^aldo?", 8, "w") self.assertEqual(actual, "w")
def test_update_letter_view_1(self): actual = pf.update_letter_view("where's taldo?", "where's xaldo?", 8, "a") self.assertEqual(actual, "x")
assert isinstance(result, bool), \ """puzzler_functions.game_over should return a bool, but returned {0}.""" \ .format(type(result)) print(' check complete') # Type check puzzler_functions.bonus_letter print('Checking bonus_letter...') result = pf.bonus_letter('water', '^^te^', 'w') assert isinstance(result, bool), \ """puzzler_functions.bonus_letter should return a bool, but returned {0}.""" \ .format(type(result)) print(' check complete') # Type check puzzler_functions.update_letter_view print('Checking update_letter_view...') result = pf.update_letter_view('apple', 'a^^l^', 2, 'x') assert isinstance(result, str), \ """puzzler_functions.update_letter_view should return a str, but returned {0}.""" \ .format(type(result)) print(' check complete') # Type check pf.calculate_score print('Checking calculate_score...') result = pf.calculate_score(4, 2, pf.CONSONANT) assert isinstance(result, int), \ """pf.calculate_score should return an int, but returned {0}.""" \ .format(type(result)) print(' check complete') # Type check pf.next_player print('Checking next_player...')