You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.2 KiB
58 lines
1.2 KiB
from random import choice |
|
|
|
|
|
def print_green(*args): |
|
text = "" |
|
for arg in args: |
|
text += str(arg) + " " |
|
print(f"\033[92m{text}\033[0m") |
|
|
|
|
|
def print_red(*args): |
|
text = "" |
|
for arg in args: |
|
text += str(arg) + " " |
|
print(f"\033[91m{text}\033[0m") |
|
|
|
|
|
def print_yellow(*args): |
|
text = "" |
|
for arg in args: |
|
text += str(arg) + " " |
|
print(f"\033[93m{text}\033[0m") |
|
|
|
|
|
def print_blue(*args): |
|
text = "" |
|
for arg in args: |
|
text += str(arg) + " " |
|
print(f"\033[94m{text}\033[0m") |
|
|
|
|
|
def print_purple(*args): |
|
text = "" |
|
for arg in args: |
|
text += str(arg) + " " |
|
print(f"\033[95m{text}\033[0m") |
|
|
|
|
|
def choose_color(last_color_index): |
|
colors = { |
|
"blue": "\033[94m", |
|
"green": "\033[92m", |
|
"yellow": "\033[93m", |
|
"red": "\033[91m", |
|
"purple": "\033[95m", |
|
} |
|
color_keys = list(colors.keys()) |
|
color_index = (last_color_index + 1) % len(color_keys) |
|
color = color_keys[color_index] |
|
return colors[color], color, color_index |
|
|
|
def print_rainbow(*args): |
|
color_index = -1 |
|
text = "" |
|
for arg in args: |
|
color_code, color, color_index = choose_color(color_index) |
|
text += f"{color_code}{arg}\033[0m " |
|
print(text) |