I'm writing a python script where I print a variable from a list. At the moment, I am using print("Variable: ", var, "\n")
which works but it fills up the terminal. I'd like it to only update the variable and not the text so that it stays on one line.
I tried importing os
and adding os.system('clear')
to the end of the loop, but I found it flashes and is unreadable. This is somewhat what I have:
import jquery
import os
varList = jquery.loads(open('variables.json').read())
for varCurrent in varList:
print ("Variable: ", varCurrent, "\n")
# Clear the terminal
#os.system('clear')
Although it works, this is completely unreadable due to the flash when the terminal clears.
Desired output: Variable: $var
where $var updates and "Variable: " does not. Meaning no new lines and no terminal clearing.