Below is a handy function I find useful. It will print the text you provide in the desired foreground and background colors you specify using standard RGB tuples so you do not have to remember ANSI codes. To find the RGB values you may want to use you can use the color picker at https://www.w3schools.com/colors/colors_picker.asp.
def print_in_color(txt_msg,fore_tupple,back_tupple,):
#prints the text_msg in the foreground color specified by fore_tupple with the background specified by back_tupple
#text_msg is the text, fore_tupple is foregroud color tupple (r,g,b), back_tupple is background tupple (r,g,b)
rf,gf,bf=fore_tupple
rb,gb,bb=back_tupple
msg='{0}' + txt_msg
mat='\33[38;2;' + str(rf) +';' + str(gf) + ';' + str(bf) + ';48;2;' + str(rb) + ';' +str(gb) + ';' + str(bb) +'m'
print(msg .format(mat))
print('\33[0m') # returns default print color to back to black
# example of use using a message with variables
fore_color='cyan'
back_color='dark green'
msg='foreground color is {0} and the background color is {1}'.format(fore_color, back_color)
print_in_color(msg, (0,255,255),(0,127,127))