0

I've just finished mario/more in pset6, however, it does not pass the tests.
The actual and expected outputs are identical, so is the expected string.
The pyramid also looks identical to the c version.

It complains about possible trailing whitespaces. However I can't see that I have any trailing whitespaces here.

Errors:
:( handles a height of 1 correctly:
expected ""# #"", not ""# #""
Did you add too much trailing whitespace to the end of your pyramid

:( handles a height of 2 correctly:
expected "" # #"\n"## ...", not "" # #"\n"## ..."
Did you add too much trailing whitespace to the end of your pyramid

Anyone know why my tests are failing? (This goes on for all tests)

def main():
    numInput = get_int_between_1_and_8()
    l = numInput - 1

    for i in range(0, numInput):

        for l in range(l):
            print(end=" ")

        for j in range(0, i+1):
            print("#", end="")

        for j in range(2):
            print (end=" ")

        for j in range(0, i+1):
            print("#", end="")
        print("\r")

def get_int_between_1_and_8():
    while True:
        n = int(input("Height: "))
        if n > 0 and n < 9:
            return n

main()
0

I solved this by changing

print("\r")

to

print("\n", end="")
| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .