We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 186806c commit f00a5f7Copy full SHA for f00a5f7
graphics/butterfly_pattern.py
@@ -8,16 +8,29 @@ def butterfly_pattern(n: int) -> str:
8
*****
9
** **
10
* *
11
+ >>> print(butterfly_pattern(5))
12
+ * *
13
+ ** **
14
+ *** ***
15
+ **** ****
16
+ *********
17
18
19
20
21
"""
22
result = []
23
24
# Upper part
- for i in range(1, n + 1):
25
+ for i in range(1, n):
26
left_stars = "*" * i
27
spaces = " " * (2 * (n - i) - 1)
28
right_stars = "*" * i
29
result.append(left_stars + spaces + right_stars)
30
31
+ # Middle part
32
+ result.append("*" * (2 * n - 1))
33
+
34
# Lower part
35
for i in range(n - 1, 0, -1):
36
0 commit comments