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
|
1407 Discussions
|
Please Login in order to post a comment
import string def print_rangoli(n): alphabet = string.ascii_lowercase lines = [] for i in range(n): left = [] for k in range (i + 1): left.append(alphabet[n-1-k]) row = left + left[:-1][::-1] line = "-".join(row).center(4*n-3, "-") lines.append(line)
if name == 'main': n = int(input()) print_rangoli(n)
Used string cropping for this one
used the logic of tiagozr to create the list of strigs with characters.
Added my logic to print (it's easier):