0
Noob question with loops in ruby
Hello Im triying to do a basic program in ruby where i make a loop for only do the next question if the first question is goodly answered but it doesn't work someone can say me why? puts "Dime cuanto dinero quieres gastarte, ¿mucho o poco?" #question 1 respuesta = 0 while respuesta == 0 dinero = gets.chomp if dinero == "mucho" or "poco" #goods answers respuesta = 1 puts "bien contestado" else puts "Las respuestas aceptadas son 'mucho' o 'poco':" respuesta = 0 end end
1 Resposta
0
You must write in the condition like this
if dinero == "mucho" or dinero=="poco"
because the "poco" is not compared to anything.so follow the code above