Не получается вывести результат алгоритма в pygame

Я решил создать приложение по расчёту ИМТ. Всё шло гладко до вывода результата моего алгоритма по поиску Имт. За вводные данные отвечает этот код найденный в интернете

input_box = pygame.Rect(300, 100, 140, 32)
color = color_inactive
#input_box1 = InputBox(350, 100, 140, 32, screen)
active = False
text = ''
# Основной цикл.
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        if event.type == pygame.MOUSEBUTTONDOWN:
            # If the user clicked on the input_box rect.
            if input_box.collidepoint(event.pos):
                # Toggle the active variable.
                active = not active
            else:
                active = False
            # Change the current color of the input box.
            color = color_active if active else color_inactive
        if event.type == pygame.KEYDOWN:
            if active:
                if event.key == pygame.K_RETURN:
                    check_grammar(screen, text)
                    text = ''
                elif event.key == pygame.K_BACKSPACE:
                    text = text[:-1]
                else:
                    text += event.unicode

В котором находится функция grammar_check для проверки введённого текста, устранения ошибок и вызов функции imt_calculator представляющего собой алгоритм расчёта ИМТ.

def check_grammar(screen, text):
    text_grammar = " .,/><':;[]{}()+=&?^%$#№@!`~"
    for sim in text_grammar:
        text = text.replace(str(sim), ',')
    result = text.split(',')
    while True:
        try:
            result.remove('')
        except ValueError:
            break
    if len(result) != 2:
        return 'Вы неправильно указали форму'
    else:
        try:
            figure_res = [int(i) for i in result]
        except ValueError:
            return 'Вы неправильно указали форму'
        else:
            received_imt = imt_calculator(figure_res)
            fontobj = pygame.font.Font('freesansbold.ttf', 20)
            textsurfaceobj = fontobj.render(received_imt, True, black, None)
            textrectobj = textsurfaceobj.get_rect()
            textrectobj.center = (300, 250)
            screen.blit(textsurfaceobj, textrectobj)

Это последний этап в моём приложении, и я буду благодарен если вы мне поможете.


Ответы (0 шт):