• Why???The solution does not pass?

Question related to mission Text Editor


text2 = Text() saver2 = SavedText() text2.write("Tomorrow at 7:15 PM.") saver2.savetext(text2) text2.setfont("ComicSans") text2.write(" Sorry. 7:15 AM.") saver2.savetext(text2) text2.write(" Near the stadium.") text2.restore(saver2.getversion(1)) text_2.show() Your result: "Tomorrow at 7:15 PM." Right result: "[ComicSans]Tomorrow at 7:15 PM. Sorry. 7:15 AM.[ComicSans]"

my solutiopn class Text: all_text = '' font = ''

def write(self, add_text):
    self.all_text += add_text

def set_font(self, new_font):
    self.font = f'[{new_font}]'

def show(self):
    return f'{self.font}{self.all_text}{self.font}'

def restore(self, back_version):
    self.all_text = back_version[0]
    self.font = back_version[1]

class SavedText: version = []

def save_text(self, textObj: Text) -> Text:
    self.version.append([textObj.all_text, textObj.font])

def get_version(self, number):
    return self.version[number]

if name == 'main': # These "asserts" using only for self-checking and not necessary for auto-testing

text_2 = Text()
saver_2 = SavedText()
text_2.write("Tomorrow at 7:15 PM.")
text_2.write(" Sorry. 7:15 AM.")
text_2.write(" Near the stadium.")