Answers to string exercises:
Remember, these should all return strings, so you need to use print(someFunction("someInput")) to test them.
#-----------------------
def quoteAndUnderline(someText):
l1 = "\"" + someText + "\""
l2 = "-" * (len(someText) + 2) # 2 extra to account for the quotes
return l1 + "\n" + l2
#-----------------------
def makeRectangle(width, height):
return ("*" * width + "\n") * height
#-----------------------
def makeTriangle(size):
s = ""
for i in range(1, size): #1 to (size-1)
s += "*"*i + "\n"
for i in range(size, 0, -1): #size downto 1
s += "*"*i + "\n"
return s