You are viewing a single comment's thread. Return to all comments →
def print_rangoli(n): a = [''] * 27 for i in range(1, len(a)): a[i] = chr(ord('a') + i - 1) for i in range(1, n + 1): s = "" t = 0 tmp = 0 while t < i: s += str(a[n - t]) tmp = n - t t += 1 while tmp < n: s += a[tmp + 1] tmp += 1 s = list(s) s = '-'.join(s) s = s.center(4 * n - 3, '-') print(s) for i in range(n - 1, 0, -1): s = "" t = 0 tmp = 0 while t < i: s += str(a[n - t]) tmp = n - t t += 1 while tmp < n: s += a[tmp + 1] tmp += 1 s = list(s) s = '-'.join(s) s = s.center(4 * n - 3, '-') print(s) if __name__ == '__main__': n = int(input()) print_rangoli(n)
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 →