Multiplying spaces with length of input
<p>python newbie here. I'm trying to print a 5 line pyramid of text based off the user's input if the string is even. I'm having trouble making the pyramid centre without hardcoding the spaces in. In line 2 I'm getting "TypeError: unsupported operand type(s) for -: 'str' and 'int' If len is returning the length and int and I'm multiply the space by that number how is this an error? Thank you :)</p>

<pre><code>userString = input( "Please enter a string with a value of 7 or less   characters: " )
space = ' '  * int( len( userString ) ) - 1
left_side = userString[:len( userString ) // 2]
right_side = userString[len( userString ) // 2:]


def pyramid( left, right ):
    print( space + left_side + right_side )
    print( space + left_side * 2 + right_side * 2 )
    print( space + left_side * 3 + right_side * 3 )
    print( space + left_side * 4 + right_side * 4 )
    print( space + left_side * 5 + right_side * 5 )
</code></pre>

<p><code>*</code> has higher precendence than <code>-</code>, so you must wrap them in parenthesis</p>

<pre><code>space = ' '  * (len(userString) - 1)
</code></pre>

python