I am a newbie who is trying to recognize Ruby. So far, I have learned some of the simplest things, but it seems like I'm stuck in trying to combine a couple of things that I have learned.
What I'm trying to do is ask the user a question and tell them to enter either 1 or 2. The simple if statement allowed me to answer with one option if they enter 1, and another option if they enter 2. However, if they enter something completely different, for example, a different number, line, etc., How can I ask them to try again and return to the original question?
What I still look something like this.
prompt = "> "
puts "Question asking for 1 or 2."
print prompt
user_input = gets.chomp.to_i
if user_input == 1
puts "One response."
elsif user_input == 2
puts "Second response."
else
puts "Please enter a 1 or a 2."
end
. " 1 2." 1 2? , , , - , , ( ) . . .