Alphabet Rangoli

  • + 0 comments
        ord_a = 97
        lines = []
        ord_last_char = size + ord_a - 1
        for num_chars in range(1, size + 1):
            left_str_list = [chr(ord_char) for ord_char in range(ord_last_char, ord_last_char - num_chars, -1)]
            string = '-'.join(left_str_list + left_str_list[-2::-1])
            line = string.center(4 * size - 3, '-')
            lines.append(line)
            print(line)
    
        for idx in range(len(lines) - 2, -1, -1):
            print(lines[idx])