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):
for i in list(range(1, size+1, 1)) + list(range(size-1, 0, -1)):
string = "-".join(chr((96)+n) for n in list(range(size, size-i, -1)) + list(range(size-i+2, size+1)))
print(string.center((2*size-1)+(2*size-2),'-'))
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): for i in list(range(1, size+1, 1)) + list(range(size-1, 0, -1)): string = "-".join(chr((96)+n) for n in list(range(size, size-i, -1)) + list(range(size-i+2, size+1))) print(string.center((2*size-1)+(2*size-2),'-'))