In this HackerRank Alphabet Rangoli problem, you are given an integer N. and you need to print an alphabet rangoli of size N.

HackerRank Alphabet Rangoli in python problem solution

HackerRank Alphabet Rangoli in python problem solution

#!python3

import operator
import string

def read_f(f): return f(input())

n = read_f(int)
mid = n-1
for row in range(n*2-1):
    line = ""
    for col in range(n*2-1):
        d = abs(row-mid) + abs(col-mid)
        if (col>0): line += "-"
        if d>=n: line += "-"
        else: line += string.ascii_lowercase[d]
    print(line)

Second solution

from string import ascii_lowercase as abc

def read_tests():
    N = int(input())
    return N

def solution(n):
    res = []
    k = 2 * n - 1
    for i in range(n):
        res.append(["-" if j + i  <  n - 1 else abc[k - i - j - 1] for j in range(n)])
    for i, row in enumerate(res):
        res[i] = row + row[-2::-1]
    res += res[-2::-1]
    return res


if __name__ == '__main__':
    test = read_tests()
    for row in solution(test):
        print("-".join(list(row)))