You are viewing a single comment's thread. Return to all comments →
used the logic of tiagozr to create the list of strigs with characters.
Added my logic to print (it's easier):
def print_rangoli(size): n = size letter = 96 + n max_len = 4*n-3 strings = [] for i in range(n): s = [] for j in range(letter, letter-i-1, -1): s.append(chr(j)) for k in range(letter-i+1, letter+1): s.append(chr(k)) strings.append("-".join(s)) for string in strings: print(string.center(max_len, '-')) strings.reverse() for string in strings[1:]: print(string.center(max_len, '-')) if __name__ == '__main__': n = int(input()) print_rangoli(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 →
used the logic of tiagozr to create the list of strigs with characters.
Added my logic to print (it's easier):