Dqnny Dqnny - 22 days ago 5
Python Question

Is it possible to append spaces and a certain amount of spaces to a string?

Here is my current code. The question is exactly in the title. (I'm looking to be able to align my triangle correctly)

def Triangle(height):
if height % 2 == 0:
print "Please enter a height that is odd"

stringTriangle = "x"
for x in range(height):
print stringTriangle
for x in range(1):


To make a string containing n spaces, use " "*n. To concatenate two strings a and b, use a + b. To learn about other things that can be done with strings, see Python 2: Built-in Types: str and Other Sequence Types.

From there, you should be able to solve your homework problem by calculating how many spaces and how many asterisks you need in each line of the figure.