0

So, I'm in pset1, and I've managed to print the half-pyramids, but one half-pyramid prints below the other half-pyramid.

I want to print one half-pyramid, then move my "cursor" back up to the very first row and "2 spaces" away from the first half-pyramid (so cursor should be on first row, but not on first column), then print the second half-pyramid.

How do I move my cursor up to the first row, after having printed the final row of the first half-pyramid?

Thank you!

0

My personal answer is "No, not really" but that's not entirely accurate. It depends highly on the hardware, the terminal and the environment. In general, if you're working a terminal type output like in the IDE, you should probably just assume no. The following link might give more insight, or you can do a google search to see if you can find a solution.

https://stackoverflow.com/questions/4872976/is-there-any-opposite-of-newline-char

Having said that, it's probably a better exercise here to learn how to intermix the for loops to print out both halves of the pyramid as you go, printing out line by line, instead of going backwards in the terminal. Learn this first, and, if you can figure out how to do what you want later, go for it. Finally, I suspect that even if you found a way to do this, it wouldn't pass check50 because check50 examines output line by line and wouldn't be able to handle the output "going backwards on the screen". It takes the output serially, so no going backwards!

If someone else has a solution to this, please post it!

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

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