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}")