I am trying to color only a single variable in Python 3, however whenever I run the code, the sring gets colored in my terminal, but then everything else after that is colored too. I am trying to do it without any imports. Here's my code.
tentativas = 20
print(f'Tentativas restantes:', f'\033[0;36m {tentativas}')
CodePudding user response:
To reset the coloring you have to use "\033[0;0m"
, either set it up as a prefix in your next print
e.g.
print("\033[0;0m This is your next print")
Or perform an empty print just to reset the color
print("\033[0;0m", end='')
CodePudding user response:
You can use the module colorama
Install: pip install colorama
Open script
from colorama import Force as color