-
Notifications
You must be signed in to change notification settings - Fork 72
/
Alphabets Rangoli
55 lines (53 loc) · 1.7 KB
/
Alphabets Rangoli
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import string
import math
def rangoli(size):
alpha = list(string.ascii_lowercase)
space = (size - 1) * 2
print(alpha)
dec = 0
ii = 1
for i in range(1, (size * 2)):
count = 1
index = size
if i <= size:
print('-' * ((size * 2 - 2) - dec), end='')
for k in range(0, ii):
if count == 1:
if k <= math.ceil(ii/2):
index = index - 1
print(alpha[index], end='')
count = 0
else:
index = index + 1
print(alpha[index], end='')
count = 0
else:
count = 1
if k != (ii - 1):
print('-', end='')
print('-' * ((size * 2 - 2) - dec), end='')
if i < size:
ii = ii + 4
dec = dec + 2
else:
ii = ii - 4
dec = dec - 2
print('-' * ((size * 2 - 2) - dec), end='')
for k in range(0, ii):
if count == 1:
if k <= math.ceil(ii / 2):
index = index - 1
print(alpha[index], end='')
count = 0
else:
index = index + 1
print(alpha[index], end='')
count = 0
else:
count = 1
if k != (ii - 1):
print('-', end='')
print('-' * ((size * 2 - 2) - dec), end='')
print()
size = int(input("Enter the Size:"))
rangoli(size)