#Feature toggles
USE_COLOR = True
TITLE_MODE = "once"
USE_BG = False
# === Title (grunge banner: IRON LUNG) ===
TITLE_GRUNGE = r"""
██╗██████╗ ██████╗ ██████╗ ███╗ ██╗ ██╗ ██╗ ██╗██╗ ██╗ ███╗ ██╗ ██████╗
██║██╔══██╗██╔═══██╗██╔═══██╗████╗ ██║ ██║ ██║ ██║██║ ██║ ████╗ ██║██╔════╝
██║██████╔╝██║ ██║██║ ██║██╔██╗██║ ██║ ██║ ██║██║ ██║ ██╔██╗██║██║ ██╗
██║██╔══██╗██║ ██║██║ ██║██║╚████║██ ██║ ██║ ██║██║ ██║ ██║╚████║██║ ╚██╗
██║██║ ██║╚██████╔╝╚██████╔╝██║ ╚███║╚█████╔╝ ╚██████╔╝╚██████╔╝ ██║ ╚███║╚██████╔╝
""".strip("\n")
# Monster face tuning
Nose = "0"
EYE_SPACING = 3 #space between the eyes
MOUTH_WIDTH = 7 #width of the mouth
PADDING_LEFT = 2 #left margin padding
#ANSI color helpers
class Color:
RESET = "\033[0m"
BOLD = "\033[1m"
FG_WHITE = "\033[97m"
FG_GRAY = "\033[90m"
FG_YELLOW = "\033[33m"
FG_MAGENTA = "\033[35m"
FG_GREEN = "\033[32m"
def style(text, *effects):
"""Apply ANSI effects if USE_COLOR is True. Otherwise return text unchanged."""
if not USE_COLOR or not effects:
return text
return f"{''.join(effects)}{text}{color.RESET}"
#grunge background
def print_grunge_background(width=100, height=8, density=0.08):
import random
chars = " .,:;i1tfLCG08@" #Light to heavy
for _ in range(height):
row = ".join(random.choice(chars) if random.random() < density else " "
for _ in range(width))
print(style(row, Color.FG_GRAY))
# Title printing (center + style)
def print_title_centered(banner: str):
try:
import shutil
width = shutil.get_terminal_size((100, 24)).columns
except Exception:
width = 100:
if USE_BG:
print_grunge_background(width=width , height=8, density=0.08)
lines = banner.splitlines()
centered = [(" " * max(0, (width - len(line)) // 2)) + line for line in lines]
print(style("\n" .join(centered), Color.BOLD, Color.FG_WHITE))
# Monster building/printing
def make_face(ch: str,
nose: str = NOSE,
eye_spaceing: int = EYE_SPACING,
mouth_width: int = MOUTH_WIDTH,
left_pad: int = PADDING_LEFT) -> str:
"""
Build a multi-line string of a simple face:
Eyes line <pad> [ch] <spaces> [ch]
Nose line: <pad + floor(spacing/2) spaces> [nose]
Mouth line: <pad> [ch * mouth_width]
"""
pad = " " * left_pad
eyes = f "{pad}{ch} {' ' * (eye_spacing}{ch}"
nose_line = f"{pad} {' ' * (eye_spacing // 2)}{nose}"
mouth = f"{pad}{ch * mouth_width}"
return "\n".join([eyes, nose_line, mouth])
def print_monster(ch: str):
if TITLE_MODE == "each":
print_title_centered(TITLE_GRUNGE)
face = make_face(ch)
lines = face.splitlines()
if USE_COLOR and len(lines) >= 3:
lines[0] = style(lines[0], Color.FG_YELLOW) #eyes
lines[1] = style(lines[1], Color.FG_MAGENTA) #nose
lines[2] = style(lines[2], Color.FG_GREEN) #Mouth
print("\n".join(lines))
print()
#Main input loop
def main():
if TITLE_MODE == "once":
print_title_centered(TITLE_GRUNGE)
while True:
user_input = input("Enter a character ('q' to quit): ").strip)
if not user_input:
print("Please enter at least one character.")
continue
ch = user_input[0]
if ch.lower() == "q":
break
print_monster(ch)
print("Goodbye. \n")
if__name__ == "__main__":
main()
To embed this project on your website, copy the following code and paste it into your website's HTML: