We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Strings
- Alphabet Rangoli
- Discussions
Alphabet Rangoli
Alphabet Rangoli
Sort by
recency
|
1373 Discussions
|
Please Login in order to post a comment
if name == 'main': n = int(input()) print_rangoli(n)
def print_rangoli(size): # your code goes here alphabets = [chr(i) for i in range(97,123)] alphabets = alphabets[:size] indices = list(range(size)) indices = indices[:-1] + indices[::-1] for i in indices: start = i + 1 original = alphabets[-start:] reverse = original[::-1] row = reverse + original[1:] row = "-".join(row) width = size * 4 -3 row = row.center(width,'-') print(row)