Print a butterfly pattern using python.
Feature description
You need to take a user input n. and print a butterfly pattern using the input received from the user as side length.
You need to print the above shown pattern from the image.
Assign me this and use label hacktoberfest.
is this issue solved? if not then assign it to me, I would like work on it.
Hey, I have optimized the code and reduced the number of lines of code. Can you assign it to me?
Hi please assign this issue to me, if it's not closed
Feature description
You need to take a user input n. and print a butterfly pattern using the input received from the user as side length.
You need to print the above shown pattern from the image.
Size of the butterfly pattern
size = 5
Upper part of the butterfly
for i in range(1, size + 1): for j in range(1, i + 1): print("", end="") for k in range(1, (2 * (size - i)) + 1): print(" ", end="") for l in range(1, i + 1): print("", end="") print()
Lower part of the butterfly
for i in range(size - 1, 0, -1): for j in range(1, i + 1): print("", end="") for k in range(1, (2 * (size - i)) + 1): print(" ", end="") for l in range(1, i + 1): print("", end="") print()
def butterfly_pattern(n): # Upper part of the butterfly for i in range(1, n + 1): # Print stars on the left side print("" * i, end="") # Print spaces in the middle print(" " * (2 * (n - i)), end="") # Print stars on the right side print("" * i)
# Lower part of the butterfly
for i in range(n, 0, -1):
# Print stars on the left side
print("*" * i, end="")
# Print spaces in the middle
print(" " * (2 * (n - i)), end="")
# Print stars on the right side
print("*" * i)
Change the value of n for a larger or smaller pattern
n = 5 butterfly_pattern(n)