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.
y = int(size)
for letter in range(1,size*2):
if x<size or x==size:
alpha_list = list(chr(i) for i in range((96+size),(96+size-x),-1))
alpha_list_reverse = alpha_list.copy()
alpha_list_reverse.reverse()
for i in alpha_list_reverse[1:]:
alpha_list.append(i)
aplha_string = "-".join(alpha_list)
print(aplha_string.center((size*4)-3,"-"))
x +=1
elif x>size:
y-=1
alpha_list = list(chr(i) for i in range((96+size),(96+size-y),-1))
alpha_list_reverse = alpha_list.copy()
alpha_list_reverse.reverse()
for i in alpha_list_reverse[1:]:
alpha_list.append(i)
aplha_string = "-".join(alpha_list)
print(aplha_string.center((size*4)-3,"-"))
if name == 'main':
n = int(input())
print_rangoli(n)
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): x = 1
if name == 'main': n = int(input()) print_rangoli(n)