print text in green color in python

You can print text in green color in Python by using ANSI escape codes.

Here's an example:

main.py
print("\033[32m" + "This text is printed in green." + "\033[0m")
65 chars
2 lines

In the above code, \033[32m represents the ANSI escape code for green color and \033[0m is used to reset the color back to the default color.

You can also define a function to make it easier to print colored text:

main.py
def print_green(text):
    print("\033[32m" + text + "\033[0m")

print_green("This text is also printed in green.")
116 chars
5 lines

This will print the text in green color.

gistlibby LogSnag