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
a = []
for char in string.ascii_lowercase:
a.append(char)
def print_rangoli(size):
y = a[:n]
c = y[::-1]
f = a[1:n]
g = f[::-1]
b = (((n*2)*2)-3)
x = int((b-1)/2)
for i in range(n-1): ### (UPPER PART)
z = c[0:i]
v = z[::-1]
print(("-".join(z)).rjust(x-1, "-") + (str(a[(n-i-1)])).center(3, "-") + ("-".join(v)).ljust(x-1, "-"))
print(("-".join(g)).ljust(int(x), "-") + str(a[0]).center(1, "-") + ("-".join(f)).rjust(int(x), "-")) ### (MIDDLE PART)
for i in range(n-1, 0, -1): ###(LOWER PART)
z = c[0:i-1]
v = z[::-1]
print(("-".join(z)).rjust(x-1, "-") + (str(a[n-i])).center(3, "-") + ("-".join(v)).ljust(x-1, "-"))
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 a = [] for char in string.ascii_lowercase: a.append(char) def print_rangoli(size): y = a[:n] c = y[::-1] f = a[1:n] g = f[::-1] b = (((n*2)*2)-3) x = int((b-1)/2)