Alphabet Rangoli

  • + 1 comment
    def print_rangoli(size):
        # your code goes here
        asciiVal = size+96
        change = -1
        char = ""
        op = []
        def makeSymmetric(s):
            return s + s[:-1][::-1]
        for i in range(size):
            char = char + chr(asciiVal)
            asciiVal = asciiVal + change
            op.append(makeSymmetric("-".join(list(str(char)))).center(size * 4 - 3, "-" ))
        for i in op:
            print(i)
        for i in range(len(op)-2, -1, -1):
            print(op[i])
    
    if __name__ == '__main__':
        n = int(input())
        print_rangoli(n)