I'm making an exercise with patterns in Python and I've did a hourglass pattern for n=5 but when I'm trying with other odd number e.g. n
==7, it's destroyed. Any suggestions how to upgrade my code?
def hourglass(num_of_rows):
#upper piece
for i in range(num_of_rows-(num_of_rows//2)):
print(' '*i+ character*(num_of_rows-2*i))
#lower piece without the middle one
for j in range(num_of_rows-1-(num_of_rows//2), -1, -2):
print(' '*(j-1) +character*(num_of_rows-j))
num_of_rows=5
character = 'x'
hourglass(num_of_rows)