Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions P/print the diamond shape
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Python program to
# print Diamond shape

# Function to print
# Diamond shape
def Diamond(rows):
n = 1
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 != (i+1):
print("*", end = " ")
n = n + 1
n = 1

# line break
print()

k = 0
n = 0
for i in range(1, rows + 1):
# loop to print spaces
for j in range (1, k + 1):
print(end = " ")
k = k + 1

# loop to print star
while n <= (rows - i):
print("*", end = " ")
n = n + 1
n = 0
print()

# Driver Code
# number of rows input
rows = 5
Diamond(rows)