You are viewing a single comment's thread. Return to all comments →
width= 2*(2*(size-1)) + 1 str='' highest_val = 97+size-1 if(size==1): print('a') else: for row in range(1,2*size): if(row <= size): # top triangle + central line substr ='' for h in range(0,row): substr += chr(highest_val-h)+'-' rsubstr = substr[::-1] # reverse of the string str += (substr + rsubstr[3:]).center(width,'-') +'\n' else: pass bottom_str=str[::-1] # reverse the whole upper triangle string + the middle line str str += bottom_str[width+2:] # remove the whole middle line + the newline character print(str)
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 →