diff --git a/Inverted_Pyramid/README.md b/Inverted_Pyramid/README.md new file mode 100644 index 00000000..c23a7753 --- /dev/null +++ b/Inverted_Pyramid/README.md @@ -0,0 +1,21 @@ +# Inverted Pyramid + +## Description + +A small Python code that generates a inverted pyramid based on a positive number typed by the user. + +## Installation + +No external dependencies are used other than native Python language. + +## Usage + +Use the following command on the terminal: + +```bash +python3 inverted_pyramid.py +``` + +## Technologies + +- Python 3.12.1 diff --git a/Inverted_Pyramid/inverted_pyramid.py b/Inverted_Pyramid/inverted_pyramid.py new file mode 100644 index 00000000..8ba17af4 --- /dev/null +++ b/Inverted_Pyramid/inverted_pyramid.py @@ -0,0 +1,10 @@ +height = int(input("Enter the height of the inverted pyramid: ")) + +while height <= 0: + print("Please enter a positive integer for the height.") + height = int(input("Enter the height of the inverted pyramid: ")) + +for i in range(height, 0, -1): + spaces = height - i + stars = 2 * i - 1 + print(" " * spaces + "*" * stars) \ No newline at end of file