Advertisement
CodingComputing

Arrow Pattern

Apr 6th, 2024
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. # *Arrow Pattern* solution by @CodingComputing
  2.  
  3. size = 7  # Given parameter
  4. all_star_row = ['*'] * size  # row consisting of all *
  5. for row_idx in range(size):  # for each row to be printed
  6.     row_chars = [' '] * size  # initialize with all spaces
  7.     row_chars[row_idx:] = all_star_row[row_idx:]  # replace upper triangle with *s
  8.     row_chars[size - 1 - row_idx] = '*'  # put single stars at other diagonal
  9.     row = ' '.join(row_chars)  # join over space into printable row
  10.     print(row)  # print!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement