When using print(“anything here”) and doing it fast (As in having some time.sleep() at like 0.1-0.5s) it gets all messed up when im in the console tab
I wanted to print some information to the console (which gets cleared quickly) and i could input things for that information to get modified.
it worked but the text i put into the console would get merged with the print()
This has happened across languages i had an issue like this in c++
it may be just an extension i have on my browser
sorry i just realized this is the wrong category im short on time while writing this
try using flush
for python:
print("example text uwu", flush=True)
let me look up the syntax for flush in c++
2 Likes
seems to not have worked i can share what i have now
Please do, either with a repl link, or your code, formatted like so:
```language-name
code
```
Yes, sharing what you have may help. 
import time
import threading
def printer(lock, stop_event):
i = 0
while True:
i += 1
time.sleep(1)
with lock:
print(f"i's value is {i}",flush=True)
lock = threading.Lock()
stop_event = threading.Event()
p = threading.Thread(target=printer, args=(lock, stop_event), daemon=True)
p.start()
if input():
print("hey look")
if input() == "stop":
print("also you said stop")
p.join()
most of this code was stolen but i just wanted to see if it was possible
modify the code to use a separate line for input because something was happening with the first lines being messed up
See if this works
while True:
i += 1
time.sleep(1)
with lock:
print(f"i's value is {i}", flush=True)
if input("Enter something: "):
print("Hey, look")
if input("Enter 'stop' to stop: ") == "stop":
print("You said stop")
break
i had to go last second should i mark your answer as the solution since it wasnt what i was really looking for (however the console output was not getting merged with the input)
I reproduced the error in another replit https://replit.com/@TG101/Typing-Simulator-Template#main.py
When typing anything the output is pushed with those letters is there no way of stopping this?
try this.
import time
import threading
lock = threading.Lock()
i = 0
def input_thread():
while True:
if input("Enter something: "):
print("Hey, look")
if input("Enter 'stop' to stop: ") == "stop":
print("You said stop")
break
input_thread = threading.Thread(target=input_thread)
input_thread.start()
while True:
i += 1
time.sleep(1)
with lock:
if not input_thread.is_alive():
print(f"i's value is {i}", flush=True)
break
What is the specific output you would like to reach?
can you give me an example?