Python Question ā 1
Alphabetic Patterns
Given a positive integer ānā less than or equal to 26, you are required to print the below pattern.
Sample Input: 5
Contents
Sample Output :
āāāeāāā
āāe-d-eāā
ā-e-d-c-d-eā-
āe-d-c-b-c-d-eā
e-d-c-b-a-b-c-d-e
āe-d-c-b-c-d-eā
ā-e-d-c-d-eā-
āāe-d-eāā
āāāeāāā
Code:
import string n = int(input())
# Write your code below
x=string.ascii_lowercase list1=[] for i in range(n): a='-'.join(x[i:n]) list1.append((a[::-1]+a[1:])) width=len(list1[0])
# or width=(4*n)-3 ; this is basically the maximum width (row length) of the matrix
for i in range(n-1,0,-1): print(list1[i].center(width,'-')) for i in range(n): print(list1[i].center(width,'-')