I'm a bit stuck in pset6 mario, hashes are printed in right number but not on the right side. I've tried to figure out myself but haven't come up with any correct solution so far so i'd really appreciate some help please.
Either use inner for loops or the multiply syntax, but not both. So either
for j in range(n - i - 1): print(" ", end="") for k in range(i + 2): print("#", end="") print()
or for example
print(" "*(n-i-1) + "#"*(i+2))
The way you're doing it, you're using the j loop the wrong way so it executes not at all, and have the i loop iterate exactly once where it should execute once per output line.
Also, you're placing everything in the while loop, while only the input request and input action should be repeated until valid input is provided.
j loop doesn't execute because of the way python
range handles a negative
step. From the python doc:
For a negative step, the contents of the range are still determined by the formula
r[i] = start + step*i, but the constraints are
i >= 0and
r[i] > stop.
j is always <=
n + 2 (the "stop").