forked from ghostmkg/programming-language
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumbered_butterfly.py
More file actions
34 lines (28 loc) · 988 Bytes
/
numbered_butterfly.py
File metadata and controls
34 lines (28 loc) · 988 Bytes
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
def print_numbered_butterfly(rows):
# Upper half of the butterfly
for i in range(1, rows + 1):
# Left wing (increasing numbers)
for j in range(1, i + 1):
print(j, end=" ")
# Spaces in the middle
for _ in range(2 * (rows - i)):
print(" ", end=" ")
# Right wing (increasing numbers)
for j in range(1, i + 1):
print(j, end=" ")
print()
# Lower half of the butterfly
for i in range(rows - 1, 0, -1):
# Left wing (increasing numbers)
for j in range(1, i + 1):
print(j, end=" ")
# Spaces in the middle
for _ in range(2 * (rows - i)):
print(" ", end=" ")
# Right wing (increasing numbers)
for j in range(1, i + 1):
print(j, end=" ")
print()
# Get input for the number of rows
num_rows = int(input("Enter the number of rows for the numbered butterfly: "))
print_numbered_butterfly(num_rows)