From 06110e1cb68a0b524a5d21b58ccc891d5c9cf897 Mon Sep 17 00:00:00 2001 From: "Lennie S." Date: Sat, 11 Apr 2026 22:45:34 +0000 Subject: [PATCH] Add ANSI colored output --- fibonacci.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fibonacci.py b/fibonacci.py index a9a4c09..dbe2692 100644 --- a/fibonacci.py +++ b/fibonacci.py @@ -1,5 +1,11 @@ #!/usr/bin/env python3 -"""Fibonacci sequence calculator.""" +"""Fibonacci sequence calculator with colored output.""" + +# ANSI color codes +GREEN = "\033[32m" +CYAN = "\033[36m" +RED = "\033[31m" +RESET = "\033[0m" def fibonacci(n: int) -> int: @@ -34,8 +40,8 @@ if __name__ == "__main__": try: n = int(sys.argv[1]) except ValueError: - print(f"Error: '{sys.argv[1]}' is not a valid integer") + print(f"{RED}Error: '{sys.argv[1]}' is not a valid integer{RESET}") sys.exit(1) result = fibonacci(n) - print(f"fibonacci({n}) = {result}") + print(f"{CYAN}fibonacci({n}){RESET} {GREEN}={RESET} {GREEN}{result}{RESET}")