[Python] Printing simultaneous lines that iterate and replace over themselves [duplicate]

Discussão em 'Python' iniciado por Stack, Setembro 15, 2025.

  1. Stack

    Stack Membro Participativo

    import time
    from motion import char
    import random
    global char
    char = {
    'seq4': '╚╔╗╝╚╔╗╝ '
    }
    def intuit():
    r = random.randint(18, 72)
    j = 0
    k = 0
    with open('intu.txt', 'r+') as f:
    num = int(input('What is the number: '))
    f.write(f'{str(num)}')
    f.seek(0)
    for i in range(r):
    if j > 8:
    j = 0
    if k > 8:
    k = 0
    print(f'\r{char['seq4'][j]} Extrapolating{char['seq6'][k:k+3]}', end='\r') #the first line to print
    print('Hello') #the second line to print
    j = j + 1
    k = k + 3
    time.sleep(0.25)
    time.sleep(0.2)
    print()
    for i in f.readlines():
    print(i)

    intuit()


    Basically, what I want to do is to print the first line, which replaces itself in a smooth loading animation. That works great. But my problem is that I also want to print the second part (the 'hello' is a placeholder). I want the second print to also replace itself for a smooth illusion of animation.

    How do I do this?

    Continue reading...

Compartilhe esta Página