From: Jan_K Date: 2006-03-31T06:38:43+09:00 Subject: Re: Learn to Program, by Chris Pine On Thu, 30 Mar 2006 10:17:55 GMT, "Dave Burt" wrote: >When you start dealing with flow control, you'll find that indenting makes a >big difference to how easy it is to read and understand your code. It is indented. Must be your client. Try this: Tools --> Options --> Read tab Check "Read all messages in plain text" >Note you've got a loop inside a loop. To get out of that, the inside loop >has to exit, and then the outside loop, and if you look at their respective >conditions (input == 'BYE') and (input != 'BYE'), that will never happen. The problem was that I didn't realize that I messed up the first Grandma program (which reinforced some misconceptions because the program was working ok). Then I sort of got this idea that I had to use a loop inside a loop and really couldn't get out of that box. Everything is obvious now. Agony of defeat, ecstacy of success. Anyway, here's the final program: (hopefully I don't have any superfluous code this time around) ----------------------------------------------------------------- number = rand(21) number2 = 0 keep_count = 0 while keep_count != 3 input = gets.chomp if input != 'BYE' keep_count = 0 puts 'HUH?! SPEAK UP, SONNY!' else number2 = (keep_count + 1) keep_count = number2 if keep_count != 3 puts 'HUH?! SPEAK UP, SONNY!' end end end puts 'NO, NOT SINCE ' + (1930 + number).to_s + '!' ---------------------------------------------------------------- -- Jan