Alphabet Rangoli

  • + 1 comment

    I made a very slight variation in the above code, and somehow i get an error in test case 3 for the input: 15. Although, as far as i can tell, my o/p is the same as the expected o/p. I'm at a complete loss. Here is my code:

    def print_rangoli(n):
        import string
        alpha = string.ascii_lowercase
        l=[]
        for i in range(n):
            s = '-'.join(alpha[i:n])
            l.append((s[::-1]+s[1:]).center(4*n-3,'-'))
        b=reversed(l[1:])
        print("\n".join(b), "\n".join(l), sep = "\n")
    

    my o/p:

    image expected o/p:

    image