Ask coding questions

← Back to all posts
Glitched Output
kineticcat

So basically I made Noughts & Crosses in python. Except every so often while using it the output just dies and starts being weird in the sense of trying to output the proper thing, But then also trying to delete it at the same time. I haven't found a solid way to trigger it but usually going either too fast or too slow usually triggers it. Does anyone have any clue as to what this could be?
I have pictures and a short clip of it if you want!
Edit: With a bit of fiddling it would seem that the problem is not with the clear() but with the print() at line 204, For some reason this line gets constantly triggered as if in a loop yet there is no code to cause that. And to make it worse I added a bit to the end of the print() to print the value of i which should increase every time the loop loops which is directly after the print(). The problem comes when the bug happens to trigger the print line lots, it shows that it is getting stuck on line 204 and never moves on or just ignores it other code as i never gets increased.

Voters
kineticcat
Comments
hotnewtop
The07Coder

By reading the previous comment, it seems you issue is that you are not able to clear the screen.

To clear the screen use the following method: (I used it in my game and it works well)

(use proper indentation)
Also if you want to clear the screen then use the function clear().

Hope This Helps!
If You Have Any Questions Just Ask Me Or Check Out My Game:
https://replit.com/@The07Coder/Idle-Factory?v=1

EthanMartin223

By vaguely looking at your code, it does not appear to be a problem with printing to stdout, nor a problem with replit's module. I believe there is a problem within your loop that causes your program to not break, and/or repeatedly clear.

Also to eliminate the need for the long import wait every time you run the program, use print("\033c",end="") or clear = lambda:print("\033c",end="") instead of replit.clear()

kineticcat

@EthanMartin223 I've replaced the from replit import clear part with what You suggested, But that didn't work. I even tried commenting out the clear() but that still did not work. Any Ideas?