0
from time import sleep
a = 30
text = ""
source = pd.read_csv("questions.csv")
questions = source["questions"]
for i in questions:
    try:
        print(i)
        text = text.join(i)
    except TypeError:
        pass
print(len(text) / 60 / a)


def plan3():#env):
    for i in range(len(text)):
        b = text[(i * a):(i * a) + a]
        print(b, end="")
        sleep(1)


plan3()

I am trying to make ^ work, but the screen doesn't update until I manually cancel the program with KeyboardInterrupt. I believe it is due to the way sleep() is coded that makes it perform the function for the required amount of time, so I am unable to change this property. The csv file has a database of questions, it can be swapped for a large string value and still it will not update "dynamically", if I am using the word correctly. I need the questions to print like a printer, line by line on the screen on the TERMINAL.

setting print("",flush = True) didn't solve for python 3.8

quamrana
  • 37,849
  • 12
  • 53
  • 71
AbhiCoder
  • 13
  • 4
  • Are you using an IDE, or are you using a terminal? – quamrana Jun 21 '21 at 08:01
  • please edit your code and add a quote in front of `questions.csv` so it doesn't run into errors when others are trying to use it – BoredRyuzaki Jun 21 '21 at 08:21
  • I am trying to use this on terminal... IDE is working well... – AbhiCoder Jun 21 '21 at 08:50
  • 1
    Does this answer your question? [How can I flush the output of the print function?](https://stackoverflow.com/questions/230751/how-can-i-flush-the-output-of-the-print-function) – quamrana Jun 21 '21 at 08:52
  • message = lambda x: print(x, flush=True, end="") message('I am flushing out now...') worked... Thank you... I'm not sure how to close this question though... – AbhiCoder Jun 21 '21 at 09:16

0 Answers0