The loop method


#1

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
end


#2

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,

to,

i-=1

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


#3

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
end

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.