The loop method


I don,t know what i did wrong can I have help?
i += 0..20
loop do
i += 1
print "#{i}"
break if i > 5


This is the main problem,'

i += 0..20

keep it simple,

i = 20 just set a starting point and have your loop code do the rest.

also change this,



Because you want to loop down and not up.

And do not change the if statement or you'll run the risk of creating an endless loop s0 leave the break if statement as is,

break if i <= 0


If you want to loop going up until 20,the code is like this:

i = 0
loop do
i += 1
print i
break if i >= 20

i starts at zero. you loop through it and everytime you loop you add 1 [.. i += 1..] print i break if i >=20
i hope this helps.