Ask coding questions

← Back to all posts
how do you color your text/print
omegawolf187 (1)

made a print but i want it to be a different color

CalebCarlson (31)


No effect: 0
Bold: 1
Underline: 2
Negative1: 3
Negative2: 5


Black: 30
Red: 31
Green: 32
Yellow: 33
Blue: 34
Purple: 35
Cyan: 36
White: 37


Black: 40m
Red: 41m
Green: 42m
Yellow: 43m
Blue: 44m
Purple: 45m
Cyan: 46m
White: 47m

The first thing you do when styling text in python is you start with an escape code. The escape code for this will always be the same.
This is the escape code:
Next, you put the code for text style:
(if you don't care what style you want just use 0)
You will always use a semi-colon to separate your style codes.
Next, you put the code for text color:
Next, you put the code for what background color you want:
The above example would show green text, bold, with a background color of yellow.
You add text by just typing directly after the m in the background color code:

print("\033[1;33;44m Charles Robison")

You put the style code directly in the string.

ArjunSS1 (113)

Caleb had a very good answer but a simple answer would be to import the colored module where colored.fore contains the different colors so you can do

From colored import fore
print(fore.RED + ‘This is red!’)
print(‘This is still red!’ + fore.WHITE)
print(“Now White!”)
CalebCarlson (31)


I had no idea that even existed XD

ArjunSS1 (113)

@CalebCarlson Yea I used to use the whole /0 system but colored is so much easier to use for small color changes