print() go wrong when multiple a string by any number, why does that happen?

Solution 1:

print separates its arguments with space, your calculations are right but there's an added space. change it to this:

import cs50

while True:
    height = cs50.get_int("Height: ")
    if height > 0 and height < 9:
        break

for i in range(1, height + 1):
    print( " " * (height - i), "#" * i, sep="")