Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how do we let the python to color change the text

+2 votes
asked Nov 22, 2025 by MennatAllah Mostafa (150 points)

1 Answer

+2 votes
answered Nov 24, 2025 by Peter Minarik (101,420 points)

It depends on the OS, more specifically, the shell that you run things in.

Since OnlineGBD is running on a Unix system, you can look at this: https://stackoverflow.com/questions/6841143/how-to-set-font-color-for-stdout-and-stderr

And for the colour codes, check https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences

Here's a sample in Python:

blue ="\033[36m"
print(f'{blue}Hello World')

Good luck!

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...