Python编写程序,对模拟打字游戏并进行成绩判定

1、编写一个程序,要求该程序运行后,生成一个名为“new.py”的文件,在每一行后面添加行号,且行号以"#"开头,即行号为注释信息,不影响程序的正常执行。同时要求所有行的"#"号垂直对齐。

import random
import string


class Game:
    def __init__(self):
        self.total_count = 0
        self.right_count = 0
        self.len = 15

    def play(self):
        n = int(input('请输入打字次数:'))
        while n:
            right = 0
            print('游戏次数剩余{}次'.format(n))
            word = ''.join(random.sample(string.ascii_letters + string.digits + ' ', random.randint(1, self.len)))
            print(word)
            res = input()
            if len(res) != len(word):
                print('输入的字符串超长,无效')
                self.total_count += len(word)
                n -= 1
                continue
            for i in zip(word, res):
                if i[0] == i[1]:
                    right += 1
            self.right_count += right
            self.total_count += len(word)
            print('本次的正确率为{:.2f}%\n'.format(right * 100 / len(word)))
            n -= 1
        print('整体的正确率为{:.2f}%'.format(self.right_count * 100 / self.total_count))


if __name__ == '__main__':
    Game().play()

谢谢大佬!..............