Ruby Ruby Loops Ruby Loops Loop Conditionals

Why doesn't this code run?

Assume get_answer() is already defined

print "What is the password?"

loop do answer = get_answer() if answer == 'e' break else print "Wrong! Try again!" end

loop.rb
# Assume get_answer() is already defined
print "What is the password?"

loop do
  answer = get_answer()
    if answer == 'e'
    break
else
    print "Wrong! Try again!"
end

3 Answers

Pedro Cabral
Pedro Cabral
22,688 Points

You have an end for the if but you are missing one for the loop.

Even when I add the other 'end', still not working... Thoughts?

Oh, whoops, yes it does. Thank you Pedro!