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.
import string
def print_rangoli(size):
# your code goes here
alphabet = string.ascii_lowercase
str = alphabet[:size] # abcde
end = len(str)-1
start = len(str)-1
for _ in range(size-1):
left = "".join(alphabet[i] for i in range(end, start, -1))
right = "".join(alphabet[j] for j in range(start, end+1, 1))
complete = "-".join(left + right)
print(complete.center(1 + 4*(size-1),'-'))
start -= 1
jump += 2
end = len(str)-1
start = 0
jump = 0
for _ in range(size):
left = "".join(alphabet[i] for i in range(end, start, -1))
right = "".join(alphabet[j] for j in range(start, end+1, 1))
complete = "-".join(left + right)
print(complete.center(1 + 4*(size-1),'-'))
start += 1
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 →
import string def print_rangoli(size): # your code goes here alphabet = string.ascii_lowercase str = alphabet[:size] # abcde
if name == 'main': n = int(input()) print_rangoli(n)