diff --git a/patterns/__init__.py b/patterns/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/patterns/pyramid_pattern.py b/patterns/pyramid_pattern.py new file mode 100644 index 000000000000..3d875cbfac41 --- /dev/null +++ b/patterns/pyramid_pattern.py @@ -0,0 +1,19 @@ +""" +Prints a pyramid star pattern. + +Example (n = 5): + * + *** + ***** + ******* +********* +""" + + +def pyramid(n: int) -> None: + for i in range(n): + print(" " * (n - i - 1) + "*" * (2 * i + 1)) + + +if __name__ == "__main__": + pyramid(5)