From: kimhyunkang@... Date: 2009-10-10T13:58:47+09:00 Subject: Re: Numbers game - multiple guesses? --001636c5b63e3e66fa04758d79a9 Content-Type: text/plain; charset=ISO-8859-1 you can do this by making an infinite loop and break from the loop when the right guess comes print "I am thinking of a number between 1 and 10 , can you guess what it is? " while true num = gets num = num.chomp num = num.to_i if num == 4 puts "You got it!" break elsif num < 4 then puts "Guess Again" elsif num > 5 then puts "Guess Again" end end 2009/10/10 John Kriple > I'm trying to figure out how to get a user to be able to submit guesses > in a guessing game multiple times. > > This is what I have so far: > > print "I am thinking of a number between 1 and 10 , can you guess what > it > is? " > > num = gets > num = num.chomp > num = num.to_i > > > if num == 4 > puts "You got it!" > elsif num < 4 then > puts "Guess Again" > elsif num > 5 then > puts "Guess Again" > > > How do I make it so they can keep guessing until they get it right? > > Thanks > -- > Posted via http://www.ruby-forum.com/. > > --001636c5b63e3e66fa04758d79a9--