We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 03a4251 commit ed4af58Copy full SHA for ed4af58
other/butterfly_pattern.py
@@ -0,0 +1,13 @@
1
+def print_butterfly(n): # defining the function
2
+ for i in range(1, n + 1): # for upper body of the butterfly
3
+ print("*" * i, end="") # for left wing of the butterfly
4
+ print(" " * (2 * (n - i)), end="") # for middle spacing
5
+ print("*" * i) # for right wing of the butterfly
6
+
7
+ for i in range(n, 0, -1): # for lower body of the butterfly
8
9
10
11
12
+n = int(input("Enter the value of n: ")) # asking the user to enter the value of n and converting the n from string to int data type
13
+print_butterfly(n)
0 commit comments