# Python butterfly star pattern
# Code by @codeswithpankaj.com
defcreate_butterfly_pattern(rows):"""
Function to create a butterfly star pattern.
:param rows: Number of rows in each wing of the butterfly.
"""foriinrange(0,rows):# Print left wing spaces
forjinrange(0,i):print("",end="")# Print left wing stars
forkinrange(0,2*(rows-i)-1):print("*",end="")# Move to the next line after each row
print()foriinrange(rows-2,-1,-1):# Print right wing spaces
forjinrange(0,i):print("",end="")# Print right wing stars
forkinrange(0,2*(rows-i)-1):print("*",end="")# Move to the next line after each row
print()# Example: Create a butterfly pattern with 5 rows in each wing
create_butterfly_pattern(5)
Top comments (0)
Subscribe
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)