1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Why is this not running without a print in Python terminal, but running in Debug?

Discussão em 'Python' iniciado por Stack, Outubro 3, 2024 às 14:02.

  1. Stack

    Stack Membro Participativo

    I am making a text adventure game in Python, using VS Code with GitHub. The menu script is as follows (at the moment).

    def menuController(menuName:str, options:list):

    print(options)
    time.sleep(0.01)

    menuPosition = 0
    for i in range(len(options)):
    if menuPosition == i:
    options = "*"+options+"* "
    else:
    options = " "+options+" "
    print(options, end="")


    menuController("ra", ["one", "two", "three", "four"])


    When I run it, it outputs this:

    ['one', 'two', 'three', 'four']


    It was missing a line at the end.

    However, when I add a print("") after the menuController is called, it outputs this:

    ['one', 'two', 'three', 'four']
    *one* two three four


    That last line is the one that I want visible in the final version

    Why does it only output the second line when it has an empty print after? Would this be fixable with some kind of output flush in the function definition?

    Continue reading...

Compartilhe esta Página