0

please please please, i am going insane, I thought python was supposed to be easier, but i can not for the life of me figure out what the hell is wrong with my code, i didn't sleep at all last night worrying about this.

import cs50 

# make sure user enters valid input
height = 0
def main():
    while True:
        # Prompt user
        print("Height: ", end="")
        height = cs50.get_int()
        if height >= 0 and height <= 23:
            break

    # for every row 
    for i in range(height):
        for j in range(height - i - 1):
            print(" ", end="")

        for k in range(i+2):
            print("#", end="")

        print("  ")

        for l in range(i+1):
            print("#")
        print("")

if __name__=="__main__":
    main()

please any help me out, I'm so close yet so far

1

First of all, chill out man! Programming should be fun, not stressful! It's like solving a mystery, not having exams! :D

Anyway your mistake is quite silly (I think it's due to the lack of sleep :P). Take a look at the following lines and find the differences, I think you can solve the rest on your own. ;)

  1. line 19:

    print("#", end="")
    
  2. lines 21 and 24:

    print("  ")
    print("#")
    

Happy coding!

| improve this answer | |

You must log in to answer this question.

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