Main function that gets user input and calls the pattern generation function.
()
| 1 | def main(): |
| 2 | """Main function that gets user input and calls the pattern generation function.""" |
| 3 | try: |
| 4 | lines = int(input("Enter number of lines: ")) |
| 5 | if lines < 0: |
| 6 | raise ValueError("Number of lines must be non-negative") |
| 7 | result = pattern(lines) |
| 8 | print(result) |
| 9 | except ValueError as e: |
| 10 | if "invalid literal" in str(e): |
| 11 | print(f"Error: Please enter a valid integer number. {e}") |
| 12 | else: |
| 13 | print(f"Error: {e}") |
| 14 | except Exception as e: |
| 15 | print(f"An unexpected error occurred: {e}") |
| 16 | |
| 17 | |
| 18 | def pattern(lines: int) -> str: |