Alphabet Rangoli

  • + 0 comments

    import string def print_rangoli(size): # your code goes here alphabet = string.ascii_lowercase str = alphabet[:size] # abcde

    end = len(str)-1
    start = len(str)-1
    
    for _ in range(size-1):
        left = "".join(alphabet[i] for i in range(end, start, -1))
        right = "".join(alphabet[j] for j in range(start, end+1, 1))
        complete = "-".join(left + right)
        print(complete.center(1 + 4*(size-1),'-'))
        start -= 1
        jump += 2
    
    end = len(str)-1
    start = 0
    
    jump = 0
    for _ in range(size):
        left = "".join(alphabet[i] for i in range(end, start, -1))
        right = "".join(alphabet[j] for j in range(start, end+1, 1))
        complete = "-".join(left + right)
        print(complete.center(1 + 4*(size-1),'-'))
        start += 1
    

    if name == 'main': n = int(input()) print_rangoli(n)