From aba090e3a2fe25b0f0445398e2c78dc7fa1a9d7a Mon Sep 17 00:00:00 2001 From: Manish Keshwani <113196913+manishkeshwani@users.noreply.github.com> Date: Fri, 28 Oct 2022 20:50:43 +0530 Subject: [PATCH] Dimond --- Diamond.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Diamond.py diff --git a/Diamond.py b/Diamond.py new file mode 100644 index 0000000..8a3ab84 --- /dev/null +++ b/Diamond.py @@ -0,0 +1,36 @@ + +def Diamond(rows): + n = 0 + for i in range(1, rows + 1): + # loop to print spaces + for j in range (1, (rows - i) + 1): + print(end = " ") + + # loop to print star + while n != (2 * i - 1): + print("*", end = "") + n = n + 1 + n = 0 + + # line break + print() + + k = 1 + n = 1 + for i in range(1, rows): + # loop to print spaces + for j in range (1, k + 1): + print(end = " ") + k = k + 1 + + # loop to print star + while n <= (2 * (rows - i) - 1): + print("*", end = "") + n = n + 1 + n = 1 + print() + +# Driver Code +# number of rows input +rows = 5 +Diamond(rows)