Oh my god. Thanks a lot.
Number of Xs in the penultimate line ... p
entered numberof the user .... n
total number of the lines... t
So now I have two more 'issues':
- get one line more than the entered number from the user (example: entered number(n) of the user is 5, I got 6 lines.)
- modify the range (?) so that the number of the X in the last is 1. Should I use while loop here? 'When you came to the number of Xs > n+4, display number of Xs as in the first line.
And the last odd line must be same as the first line.
Odd lines must be blank = spacing between lines with Xs. So can I use '\n '?
Number of Xs in the penultimate line ... p
entered numberof the user .... n
total number of the lines... t
So now I have two more 'issues':
- get one line more than the entered number from the user (example: entered number(n) of the user is 5, I got 6 lines.)
- modify the range (?) so that the number of the X in the last is 1. Should I use while loop here? 'When you came to the number of Xs > n+4, display number of Xs as in the first line.
def print_spruce(n): for size in range(1, n+5, 2): print((size * "X").center(n+5)) n = int(input("Write the size of the spruce:")) print_spruce(n)terminal:
Write the size of the spruce:5 X XXX XXXXX XXXXXXX XXXXXXXXXThe 'odd lines' must be blank.
And the last odd line must be same as the first line.
Odd lines must be blank = spacing between lines with Xs. So can I use '\n '?
def print_spruce(n): for size in range(1, n+5, 2): (size * "X").center(n+5) for x in range(1, n+5, 2):print "line \n" n = int(input("Write the size of the spruce:")) print_spruce(n)terminal:
File "assign.py", line 4 for x in range(1, n+5, 2):print "line \n" ^ IndentationError: unindent does not match any outer indentation level