Can you please help? battling with next command in ruby


Exercise 9 - loops and interators

Can you please help? I've been battling with the next command in Loops and iterators where I need to drop the odd numbers for 3 days and am drawing blanks.

My code is 

for i in 1..20
  next if i % 1 == 0
  print "{#i}"

Thanks for your help


Odd numbers have a modulo of 1 when divided by 2. That means greater than zero, or not equal to zero; either way.

next if i % 2 != 0
print "#{i}"

prints only even numbers,

next if i % 2 == 0
print "#{i}"

prints only odd numbers.


thanks mtf, I am seeing the even numbers now but I am still getting the error message "looks like your loop doesn't print out the number 18 to 0"


Don't panic I came right, went back to basics and it worked