Skip to content

Commit

Permalink
Merge pull request #31 from raypretam/Hour_Glass
Browse files Browse the repository at this point in the history
Added hour_glass_pattern.py
  • Loading branch information
akshitagupta15june authored Sep 25, 2020
2 parents e4105c3 + a6f5eca commit 1b04501
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Patterns/hour_glass_pattern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
def hour_glass_pattern(n):

# loop for printing the upper half
for i in range(n+1):

# printing the spaces at the beginning
for k in range(i):
print(" "*2, end="")

# printing the values in each row
for j in range(-(n-i), (n-i+1)):
print(abs(j), end=" ")

print()

# Loop for printing the lower half
for i in range(1, n+1):

# Printing spaces at the beginning
for k in range(n-i):
print(" "*2, end="")

# Printing values in each row
for j in range(-i, i+1):
print(abs(j), end=" ")

print()


n = int(input("Enter the number of rows : "))
hour_glass_pattern(n)

0 comments on commit 1b04501

Please sign in to comment.