You are viewing a single comment's thread. Return to all comments →
import string def print_rangoli(size): # variables length = 4 * size - 3 lower = list(string.ascii_lowercase) strlist = [] # top newstr = '' for i in range(size - 1,-1,-1): if i == size - 1: newstr = lower[i] else: newstr = newstr[0: int(len(newstr)/2) + 1]+ '-' + lower[i] + '-' + newstr[int(len(newstr)/2):] strlist.append(newstr) print(newstr.center(length, '-')) # bottom for i in range(len(strlist) - 2, -1, -1): print(strlist[i].center(length, '-'))
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 →