Skip to content
← Back to Community
🐍 Python Text Styles 🐍 [UPDATED!]
Profile icon
SilvermoonCat

Python Text Styles!

Today we're going to learn:

  • italic, bold, underline
  • all the colors (I know)

Alright! Let's begin:

print("Welcome to python text style tutorials.")

How do we make that text prettier?

First, let's add color

To add color, you can import it. However, a fancier way can be used (I prefer this way).

print("\033[0;36mblue text :D")

WWHHAAT?

So, add the \033[ first.
After that, add either 0,1,2,3 or 4.
0: Normal text
1: Bold
2: Pale
3: Italic
4: Underline

psst: TIPS!
If you are doing let's say pale then bold,
Make sure to do \033[0;1;39m (You can change
the color, of course) But please remember to
clarify it's not pale anymore-
With the 0. Or else... dun dun dun

Alright. Now add that, and we have

print("\033[1;Colored text")

You run the code.

Er, it's not working

Right. We must add the color. Go to main.py to see more, but you can also stay here.
Red: 31
Orange: 33
Yellow: 93
Green: 32
Cyan: 36
My favorte, light blue: 94
Blue: 34
Purple: 35
Gray: 37
White: 39

print("\033[1;36Colored text)

Still not working.

Add a m after the number for your color.
e.g. "\033[1;36mColored text"

phew!

also: Here’s a easy shortcut!
You can list them out: e.g.
cyan = "\033[1;36m" white = "\033[1;39m" reset = "\033[0m"
then use them like:
print(cyan + "Cyan text" + reset)
Should be working now, have fun using the colors! If you discover any new colors or have any questions, comment here.

Voters
Profile icon
WolfiePup0703
Profile icon
WillStenzel1
Profile icon
aod19aabwdy
Profile icon
superguy123456
Profile icon
bitFez
Profile icon
MaryamKashif
Profile icon
ShuaibNuruddin
Profile icon
soupa
Profile icon
8BitHeartAttack
Profile icon
MajdZaher
Comments
hotnewtop
Profile icon
Bookie0

umm that is very annoying use variables that hold the ANSI escape codes lol..

Profile icon
[deleted]

Can you also use RGB-colors for printing a string?

Profile icon
SilvermoonCat

@ZhongRietveld I don’t think so but I’m not like a python color expert or smth so maybe you could search it up? I really wish they would allow RGB colors or hex codes. If you find anything interesting you can tell me!! ↓

Profile icon
[deleted]

@SilvermoonCat I had search it on the internet and guess what? You can RGB color print!

print("\033[38;2;R;G;BmHello World")

Profile icon
SilvermoonCat

@ZhongRietveld wow, cool! I’ll try it sometime :D

Profile icon
EdibleWaffle

Gray just looks white

Profile icon
ahkid7674

how do you do yellow

Profile icon
SilvermoonCat

@JULIODIAZ1 ooh I should add that...

print("\033[1;93mThis is yellow text") #bolded because of the 1
Profile icon
ahkid7674
Profile icon
SenatorBinks

Nice job, this is pretty helpful

Profile icon
SilvermoonCat

thanks :) @FloCal

Profile icon
LuckyOreos

I already know most of these but it’s one of the things I always suggest to people and it’s just what every python repl needs!!! It’s not toooooo coding related but nice job!!!

Profile icon
SilvermoonCat

@LuckyOreos
thanks :D Since I'm not good at codes so i have to do this stuff--

Profile icon
LuckyOreos

@SilvermoonCat It’s alright you still put in a lot of effort