How to print to console in color?

python, ubuntu

Solution

Define color like this:

W  = '\033[0m'  # white (normal)
R  = '\033[31m' # red
G  = '\033[32m' # green
O  = '\033[33m' # orange
B  = '\033[34m' # blue
P  = '\033[35m' # purple

print(R+"hello how are you"+W)

Demo:

see all color codes here:Color Codes

Problem

How to print in color using python print. For example ``` print('This should be red') print('This should be green') ``` Now everything is white text on black background. I use ubuntu, if it helps.

Original source

Related problems