We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def print_rangoli(size):
s,l='',[]
if size==1:
print('a')
else:
for i in range(96+size,96,-1):
for j in range(96+size,i-1,-1):
s=s+chr(j)+'-'
if len(s)!=2:
l.append((s+s[len(s)-4::-1]).center((size-1)*4+1,'-'))
else:
l.append(s.center((size-1)*4+1,'-'))
s=''
for h in l:
print(h)
for k in l[len(l)-2::-1]:
print(k)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Alphabet Rangoli
You are viewing a single comment's thread. Return to all comments →
def print_rangoli(size): s,l='',[] if size==1: print('a') else: for i in range(96+size,96,-1): for j in range(96+size,i-1,-1): s=s+chr(j)+'-'