8. The Loop Method


I can't seem to figure out how to get this right I continue to get a message saying it looks like your loop doesn't print out the numbers 19 to 0. This is my code:
i = 0
loop do
i += 1
print "#{i}"
break if i > 5


break if i>5

The above line instructs to break out of the loop if i becomes greater than 5. Change it to 19. This should allow you print numbers 0 through 19. Also, you're adding one to your index before printing its value, which is most likely giving you an initial value of "#1" instead of "#0".

If you really want to make it descend from 19 to 0, you would want to set i to 19, then subtract 1 from index i after printing it, and make your condition if i < 0.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.