Given an integer n, print the following pattern using alphabets in Python

0 votes
asked Sep 29, 2018 by Venkat
#Size 5

--------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--------

1 Answer

0 votes
answered Jan 7 by anonymous
import string

n = int(input())

a = string.ascii_lowercase

# Write your code below

List = []

for i in range(n):

    s = "-".join(a[i:n])

    List.append(s[::-1]+s[1:])

width = len(List[0])

for i in range(n-1, 0, -1):

    print(List[i].center(width, "-"))

for i in range(n):

    print(List[i].center(width, "-"))
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...