You can print text in Terminal (Console) in Python using ANSI Codes.
Below are a few examples of color codes:
color_blue_ANSI_code = '\033[94m'
color_red_ANSI_code = '\033[91m'
color_green_ANSI_code = '\033[92m'
color_yellow_ANSI_code = '\033[93m'
You will need to reset the color, to choose another one or default back to white.
reset_color = '\033[0m'
Example:
''' Colored Text Example
By: Code2care.org
'''
#
color_blue_ANSI_code = '\033[94m'
color_red_ANSI_code = '\033[91m'
color_green_ANSI_code = '\033[92m'
color_yellow_ANSI_code = '\033[93m'
# Reset color code
reset_color = '\033[0m'
# Print colored text
print(color_red_ANSI_code + 'This will be printed in Red Color' + reset_color)
print(color_blue_ANSI_code + 'Blue blue Skies!!' + reset_color)
print(color_yellow_ANSI_code + '...and it was all Yellow!' + reset_color)
print(color_green_ANSI_code + 'The World Needs to Go Green!' + reset_color)
Terminal Output:

Have Questions? Post them here!
- Program 11: Calculate Percentage - 1000+ Python Programs
- Program 8: Multiply Two Numbers - 1000+ Python Programs
- Program 1: Print Hello World! - 1000+ Python Programs
- 20 - Python - Print Colors for Text in Terminal - 1000+ Python Programs
- Program 15: Find String is a Palindrome or Not - 1000+ Python Programs
- 17: Find Factorial of a Number - 1000+ Python Programs
- Program 13: Reverse a String - 1000+ Python Programs
- 18: Get Sub List By Slicing a Python List - 1000+ Python Programs
- Program 9: Divide Two Numbers - 1000+ Python Programs
- Program 7: Find Difference of Two Numbers - 1000+ Python Programs
- Program 14: Sum of Even Numbers from 1 to 100 - 1000+ Python Programs
- Program 10: Modulo of Two Numbers - 1000+ Python Programs
- 16: Find the largest element in a List - 1000+ Python Programs
- Python Program: Use NumPy to generate a random number between 0 and 1
- Program 2: Print your name using print() function - 1000+ Python Programs
- 19: Simple Calculator using built-in functions - 1000+ Python Programs
- Program 6: Find Sum of Two Floating Numbers - 1000+ Python Programs
- Program 12: Calculate Area and Circumference of Circle - 1000+ Python Programs
- Program 5: Find Sum of Two Integer Numbers - 1000+ Python Programs
- Program 4: Input Name and Age and Print - 1000+ Python Programs
- Program 3: Print the name of user as input - 1000+ Python Programs
- Fix: Unable to edit text in TextEdit on Mac - MacOS
- [Fix] Restricted View permission level missing in SharePoint Online site library - SharePoint
- Android EditText Cursor Colour appears to be white - Android
- 17: Find Factorial of a Number - 1000+ Python Programs - Python-Programs
- What is Terminal Velocity and its Formula? How to calculate it programmatically? - Python
- Know Bash shell version command - Bash
- [Fix] Linux - bash: useradd: command not found - Linux
- 97 Useful Notepad++ Keyboard Shortcuts - NotepadPlusPlus