From: Dave Aronson Date: 2011-10-14T11:29:19+09:00 Subject: Re: Learning Ruby question regarding Looping On Tue, Oct 11, 2011 at 11:27, Dennis Nguyen wrote: > But I need some help to understand looping. Try thinking like the computer. Remember, it's wonderfully fast and has a (nearly) flawless memory... but it does only exactly what you tell it to do, not what you *want* it to do, or what any human can clearly see you (almost certainly) meant. Step through the program, pretending to be the computer. Note the values of the variables, the results of comparisons, any input or output, etc. Try it with different input values. Way Back When, we used to call this "hand simulation", dirty as that may sound. ;-) In this particular case, assuming the reply wasn't "yes", you'll note yourself asking "What!?" over and over. Ask yourself why you're doing that over and over. It's because each time you check the answer, it isn't "yes" -- and it *keeps on* not being "yes". Ask yourself, how can I make it *become* "yes"? The answer is, you have to let the user type it in again. Then the light bulb should turn on over your head, regarding where the "reply = gets.chomp" needs to be. :-) -Dave -- LOOKING FOR WORK, preferably Ruby on Rails, in NoVa/DC; see main web site. Main Web Site: davearonson.com Programming Blog: codosaur.us Excellence Blog: dare2xl.com