-
Notifications
You must be signed in to change notification settings - Fork 0
/
alpha-pattern.py
33 lines (24 loc) · 913 Bytes
/
alpha-pattern.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#create a dictionary with square_of_letters()
def square_of_letters(layers):
List_of_letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z']
result = []
for i in range(layers):
# updating existing rows
for j, pattern in enumerate(result):
result[j] = List_of_letters[i] + pattern + List_of_letters[i]
#print(pattern, result)
# adding top and bottom row
result.append((i*2 + 1)*List_of_letters[i])
if i != 0:
result.insert(0, (i*2 + 1)*List_of_letters[i])
for res in result:
print(res)
def main():
""" main function """
# Get your number of layers
n = int(input("Layers: "))
square_of_letters(n)
if __name__ == "__main__":
main()