You are viewing a single comment's thread. Return to all comments →
def print_rangoli(size): # your code goes here width = (size * 4) -3 alphabet = "abcdefghijklmnopqrstuvwxyz" substr = alphabet[0:size][::-1] #reversed substring eg. edcba
lines_above = ["-".join(substr[0:i+1] + substr[0:i+1][:-1][::-1]).center(width, '-') for i in range(size)] lines_below = [*reversed(lines_above[:-1])] rangoli = lines_above + lines_below print(*rangoli, sep="\n")
Seems like cookies are disabled on this browser, please enable them to open this website
Alphabet Rangoli
You are viewing a single comment's thread. Return to all comments →
def print_rangoli(size): # your code goes here width = (size * 4) -3 alphabet = "abcdefghijklmnopqrstuvwxyz" substr = alphabet[0:size][::-1] #reversed substring eg. edcba