Noob question with loops in ruby | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

7th Nov 2016, 5:10 PM
Martín Hernández Deincognito
Martín Hernández Deincognito - avatar
1 Answer
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
8th Nov 2016, 9:58 AM
Nazrul Affiq
Nazrul Affiq - avatar