Quick actions

cmd+k|ctrl+k

Navigation

Languages

29 Цветной текст из подпрограммы

Snippet info

Language

Python

Visibility

public

Author

python100

Created

2025-07-30T18:12:20.80975Z

Updated

2025-07-30T18:12:20.80975Z

#Выводит текст заданным цветом
def color_print(text, color):
    if color == "black":
        print("\033[30m", text, "\033[0m", sep="", end="")
    elif color == "red":
        print("\033[31m", text, "\033[0m", sep="", end="")
    elif color == "green":
        print("\033[32m", text, "\033[0m", sep="", end="")
    elif color == "yellow":
        print("\033[33m", text, "\033[0m", sep="", end="")
    elif color == "blue":
        print("\033[34m", text, "\033[0m", sep="", end="")
    elif color == "magenta":
        print("\033[35m", text, "\033[0m", sep="", end="")
    elif color == "cyan":
        print("\033[36m", text, "\033[0m", sep="", end="")
    elif color == "white":
        print("\033[37m", text, "\033[0m", sep="", end="")
    else:
        print(text, sep="", end="")

# Выводим текст
print("Super Subroutine")
print("With my new program I can just call ", end="")
color_print("""red("and") """, "red")
color_print("and that word will appear in the color I set it to.", "blue")
color_print("With no weird gaps. ", "cyan")
color_print("Epic.", "green")
INFO