Advertisement
PowerCell46

Christmas Tree Python

Feb 3rd, 2023
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. import copy
  2.  
  3. input_number = int(input())
  4.  
  5. last_row_list = []
  6.  
  7. list_print = [" ", "|", " "]
  8.  
  9. for i in range(0, input_number):
  10.     list_print.append("*")
  11.     list_print.insert(0, "*")
  12.     if i == (input_number - 1):
  13.         last_row_list = list_print
  14.  
  15. reversed_list = copy.deepcopy(last_row_list)
  16. n = 0
  17. print_row = copy.deepcopy(last_row_list)
  18.  
  19. while "*" in last_row_list:
  20.     n += 1
  21.     index_1 = last_row_list.index("*")
  22.     last_row_list.pop(index_1)
  23.     last_row_list.insert(index_1, " ")
  24.  
  25.     index_2 = len(last_row_list) - n
  26.     last_row_list.pop(index_2)
  27.     last_row_list.insert(index_2, " ")
  28.     copy_list = copy.deepcopy(last_row_list)
  29.     reversed_list.append(copy_list)
  30.  
  31. for index in range((len(reversed_list) - 1), -1, -1):
  32.     if index == (len(reversed_list) - input_number -1):
  33.         break
  34.     current_list = reversed_list[index]
  35.     print("".join(current_list))
  36.  
  37. print("".join(print_row))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement