def print_pyramid(n): for i in range(n): print(' ' * (n - i - 1) + '*' * (2 * i + 1)) print_pyramid(int(input("Enter a number:")))