1

So im trying to make a script using Lexing and Parsing. I wanted to try and change the color of the texts when a user inputs something.

Say in python when I do: '''print("Hello")''' It changes the color of print, string, parens, etc. I just wanted to know how to do it and/or the code to do it.

Say if my user types: '''hello NAME''' It will change the color of "hello" to green or something. Does anyone know how?

Snek
  • 11
  • 3

2 Answers2

0

You can do like this

import colorama
from colorama import Fore

print(Fore.RED + 'This text is red in color')
Sarim Sikander
  • 351
  • 2
  • 15
-1

Try using colorama, or termcolor in python:

Here is a link: https://www.geeksforgeeks.org/print-colors-python-terminal/

Dharman
  • 30,962
  • 25
  • 85
  • 135
VMSM
  • 15
  • 4
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 02 '22 at 08:10