def run(flashcard: Flashcard, hint_rate=None):
n = len(flashcard)
num_collect = 0
for i, card in enumerate(flashcard):
problem = card[0]
expected = card[1]
print("# {:02d}".format(i + 1), problem)
if hint_rate is not None:
print(colored("hint", "blue"), hint(expected, hint_rate))
ans = input(">>>> ")
if expected == ans.strip():
num_collect += 1
print(colored('GOOD', 'green'), colored(expected, "green"))
else:
expected_with_mistake, ans_with_mistake = get_diff_with_color(expected, ans)
print(colored('MISS', 'red'), expected_with_mistake)
print(' ', ans_with_mistake)
print("*" * 100)
print("{}/{}".format(num_collect, n))
评论列表
文章目录