I've been working on this for a while and feel stuck. I think that my "for" loops might be out of order or some other issue. Suggestions? Thanksenter image description here

2 Answers 2


Looks like you have an extra for loop there, which will cause the entire thing to loop l times when that's probably not what you intended.

  • Which loop do you think is extra? Thanks!
    – Patsy Lin
    Commented Jan 15, 2022 at 22:24
  • @PatsyLin the one directly below the do-while loop. Commented Jan 16, 2022 at 11:44
  • Awesome. It works now. Hooray!
    – Patsy Lin
    Commented Jan 16, 2022 at 18:55

in your code check the first for loop, why is the counter decreasing ?

why do you need 4 for loops?

to create the right aligned pyramid you need only 3 for loops.

  1. external loop, to count from the top of the pyramid down to the base

  2. first inner loop to print the dots or spaces, using --

  3. second inner loop to print the #, using ++

You must log in to answer this question.

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