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:

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!