-1

This is my simple code. It does not work in PyCharm but it's working in cmd

import time
dic = ['....','...=','..=.','.=..','=...']

while True :
 for i in range(len(dic)):
   print(dic[i],end='\r')
   time.sleep(.3)
jps
  • 20,041
  • 15
  • 75
  • 79
  • *how* is it not working? [ask] and [mre] – Julien Jul 26 '22 at 07:57
  • Does this answer your question? [PyCharm print end='\r' statement not working](https://stackoverflow.com/questions/34950201/pycharm-print-end-r-statement-not-working) – JanMalte Jul 26 '22 at 08:28

1 Answers1

0

There is indeed an issue with PyCharm which seems to have an issue with the print(end='\r') combined with time.sleep(). Here is a workaround I found :

for x in range (len(dic)):

    b = dic[x]
    sys.stdout.write('\r'+b)
    time.sleep(0.5)
ohpif
  • 19
  • 5
  • @JanMalte Well I didn't looked for it, but when searching on StackOverflow I found a similar response to the one MadushanPramod made and somes answers were pointing out it did not work (even if the response got +100 upvotes) So it seemed to work for some people... – ohpif Jul 26 '22 at 08:31