A command-line Python program that generates a symmetrical hollow diamond-style pattern using a user-defined symbol and an odd-sized width.
The program validates user input, enforces odd-number constraints, and dynamically builds the pattern using loops and spacing logic.
- Generates a symmetrical star/symbol pattern
- Enforces odd-number input only for correct symmetry
- Allows the user to choose any symbol for the pattern
- Input validation for:
- Non-numeric values
- Even numbers
- Clean top, middle, and bottom pattern structure
- The pattern width is defined by an odd number
n - The pattern consists of:
- A full top line
- An expanding upper half
- A contracting lower half
- A full bottom line
- Spaces are calculated dynamically to maintain symmetry
Input
- Number of pattern:
5 - Symbol:
*
Output
*****
** **
* *
** **
*****
- Functions
- Input validation
- While loops
- For loops
- String multiplication
- Pattern symmetry logic
python star_pattern_versatile.py